activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From write2sambit1 <sambitkumohanty...@gmail.com>
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:

Publisher.java::::
import java.net.UnknownHostException;
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 java.net.InetAddress;
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();
        
        connection.start();
        
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        producer = session.createProducer(null);

    }

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

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


        publisher.close();

	}

    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)192.34.52.12
                                                       2)192.34.53.11
                                                        ...................
                                                       100)192.34.53.15
I want the my Publisher.java send the MQSever/Broker message using the first
ipaddress ie.192.34.52.12
               my Publisher1.javasend the MQSever/Broker message using the
first ipaddress ie.192.34.53.11.

Iwant to build my client (Publisher.java) 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: http://www.nabble.com/ActiveMQ-Producer-and-IP-Address-builnding-tp23364157p23364157.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Mime
View raw message