activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From write2sambit1 <>
Subject ActiveMQ Producer and IP Address builnding
Date Mon, 04 May 2009 07:18:36 GMT

Dear Developer,

I have created a activeMQ Producer using the following codes:
import javax.jms.Connection;
import javax.jms.ConnectionConsumer;
import javax.jms.ConnectionFactory;
import javax.jms.ConnectionMetaData;
import javax.jms.Destination;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Queue;
import javax.jms.QueueSession;
import javax.jms.ServerSessionPool;
import javax.jms.Session;
import javax.jms.QueueConnection;
import javax.jms.Topic;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.ActiveMQConnectionFactory;

public class Publisher {

    private static String brokerURL = "tcp://localhost:61616";
    private  ConnectionFactory factory;
    private  Connection connection;
    private  Session session;
    private  MessageProducer producer;

    private static int count = 10;
    private static int total;
    private static int id = 1000000;

    //private String jobs[] = new String[]{"suspend", "delete"};

    public Publisher() throws JMSException, UnknownHostException {
    	factory = new ActiveMQConnectionFactory("bla-pc34198","",brokerURL);
       	connection = factory.createConnection();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        producer = session.createProducer(null);


    public void close() throws JMSException {
        if (connection != null) {

	public static void main(String[] args) throws JMSException,
UnknownHostException {
    	Publisher publisher = new Publisher();



    public void sendMessage() throws JMSException, UnknownHostException {
        Destination destination = session.createQueue("TEST.FOO");
        Message message = session.createObjectMessage("1111111111111");
        System.out.println("Sending: id:  on queue: " + destination);
        producer.send(destination, message);

This code is working fine.Now I need a modification in this code.
My Requirment is to buind the IPAddress to this Publisher.In Detalis:
Suppose I have the Following Ip address:1)
I want the my send the MQSever/Broker message using the first
ipaddress ie.
               my Publisher1.javasend the MQSever/Broker message using the
first ipaddress ie.

Iwant to build my client ( to one particular ip address so
that the broker diffrenciate them on the basis  of their....

#Wait for your's Response.

View this message in context:
Sent from the ActiveMQ - Dev mailing list archive at

View raw message