Friday, June 26, 2015

Compiling and Running using Mono

Introduction...

Hi All,

Following are a basic set of "mono" commands that allows to run .NET code. These commands ran on MAC OS X.

Compiling code to an EXE

Here we are going to compile a C# code using "mcs" command that comes with Mono. Lets say we have the following code with the name of the file being "hello.cs".

using System;
 
public class HelloWorld
{
    static public void Main ()
    {
        Console.WriteLine("Hello Mono World");
    }
}

To compile the code to an EXE, run the following command.

mcs hello.cs

Running the above command would create an a file named "hello.exe". To execute the "hello.exe", run the following command.

mono hello.exe

The above should print the output as "Hello Mono World".

Now lets say there is an external DLL dependency file which is needed to compile the program successfully. To do so, run the following command.

mcs hello.cs -r:My.Reference.dll

Goodluck!!!

References...

Thursday, June 25, 2015

Configuring ActiveMQ to MySQL Database

Introduction...

Hi All,

By default, ActiveMQ broker uses KahaDB as the persistence message store. In the following post we will be configuring ActiveMQ to use a MySQL database.

Steps 1

Modify the "activemq.xml" file which is located at "<ACTIVEMQ_HOME>/conf/" folder. Here we have to add a bean which contains the connection details for the MySQL database and also have to indicate that we are gonna use MySQL as the message store.

Add the MySQL database connection information as below.

<beans .....>
    ......
    <bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost/activemq"/>
        <property name="username" value="root"/>
        <property name="password" value="root"/>
        <property name="poolPreparedStatements" value="true"/>
    </bean>
    ......
</beans>

Remove the KahaDB message store and add the MySQL message store.

<beans .....>
    <broker .....>
        ......
        <persistenceAdapter>
            <jdbcPersistenceAdapter dataSource="#mysql-ds"/>
            <!-- <kahaDB directory="${activemq.data}/kahadb"/> -->
        </persistenceAdapter>
        ......
    </broker>
</beans>

Steps 2

Add the MySQL driver to "<ACTIVEMQ_HOME>/lib/optional/" folder

And thats all folks.

References...

[1] - http://activemq.apache.org/how-to-configure-a-new-database.html
[2] - http://activemq.2283324.n4.nabble.com/ActiveMQ-4-0-won-t-start-td2343357.html