Friday, June 26, 2015

Compiling and Running using Mono


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



Thursday, June 25, 2015

Configuring ActiveMQ to MySQL Database


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"/>

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

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

Steps 2

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

And thats all folks.


[1] -
[2] -