// shall I write some keywords here to boost search engine ranking?

Showing posts with label ActiveMQ. Show all posts
Showing posts with label ActiveMQ. Show all posts

Saturday, January 09, 2010

Send Message to ActiveMQ via WGET

In ActiveMQ website, it does show the steps of consuming message from ActiveMQ via WGET.


In order to produce message and send into ActiveMQ queue, here is the command:
wget --post-file=message.txt http://localhost:8161/demo/message/MyQueue?type=queue

Where the message.txt is something like this:
body=the test message you would like to submit.
Reblog this post [with Zemanta]

Sunday, September 21, 2008

ActiveMQ Failover with Async Send

Apche ActiveMQ is a popular open source JMS Message Broker. As in version 5.0, it support failover transport, and async send. But not both at the same time.

Both connection string below will NOT work:

failover:(tcp://remotehost:61616,tcp://localhost:61616)?jms.useAsyncSend=true
failover:(tcp://remotehost:61616?jms.useAsyncSend=true,tcp://localhost:61616?jms.useAsyncSend=true)

So the dirty trick I use is to write my own ContextFactory that override 'org.apache.activemq.jndi.ActiveMQInitialContextFactory'


package org.apache.activemq.jndi;

import java.net.URISyntaxException;
import java.util.Hashtable;

import org.apache.activemq.ActiveMQConnectionFactory;

public class ActiveMQOptimisedSendInitialContextFactory extends ActiveMQInitialContextFactory{

@Override
protected ActiveMQConnectionFactory createConnectionFactory(
Hashtable environment
) throws URISyntaxException {
ActiveMQConnectionFactory connFactory = super.createConnectionFactory(environment);

connFactory.setUseAsyncSend(true);

return connFactory;

}

@Override
protected ActiveMQConnectionFactory createConnectionFactory(
String name,
Hashtable environment
) throws URISyntaxException {
ActiveMQConnectionFactory connFactory = super.createConnectionFactory(name, environment);

connFactory.setUseAsyncSend(true);

return connFactory;
}

}


Using this class as JNDI's 'java.naming.factory.initial', then the connection will be using async send by default, inlude failover transport.