def run(self, brokerURL="tcp://192.168.1.103:61616", queueName="test"):
         factory=ActiveMQConnectionFactory(brokerURL)
         connection = factory.createConnection()
         connection.start()
         session = connection.createSession(False, Session.AUTO_ACKNOWLEDGE)
         destination = session.createQueue(queueName)
         consumer = session.createConsumer(destination)
         consumer.setMessageListener(self)
 def Producer(self, brokerURL="tcp://192.168.1.103:61616", queueName="test"):
         self.factory=ActiveMQConnectionFactory(brokerURL)
         self.connection=self.factory.createConnection()
         self.connection.start()
         self.session = self.connection.createSession(False, Session.AUTO_ACKNOWLEDGE);
         self.destination = self.session.createQueue(queueName);
         self.producer = self.session.createProducer(self.destination);
class MyProducer():
        factory, connection, session, producer = (None,None,None,None)
        def Producer(self, brokerURL="tcp://192.168.1.103:61616", queueName="test"):
                self.factory=ActiveMQConnectionFactory(brokerURL)
                self.connection=self.factory.createConnection()
                self.connection.start()
                self.session = self.connection.createSession(False, Session.AUTO_ACKNOWLEDGE);
                self.destination = self.session.createQueue(queueName);
                self.producer = self.session.createProducer(self.destination);
        def run(self):
                [self.message(u"Hello World!") for x in range(100)]
        def message(self, m):
                print "Sending: " + repr(m)
                message = self.session.createTextMessage(m)
                self.producer.send(message)
        def close(self):
                try:
                        self.connection.close()
                except:
                        pass
Example #4
0
class MyProducer:
    factory, connection, session, producer = (None, None, None, None)

    def Producer(self, brokerURL="tcp://192.168.1.103:61616", queueName="processing-output"):
        self.factory = ActiveMQConnectionFactory(brokerURL)
        self.connection = self.factory.createConnection()
        self.connection.start()
        self.session = self.connection.createSession(False, Session.AUTO_ACKNOWLEDGE)
        self.destination = self.session.createQueue(queueName)
        self.producer = self.session.createProducer(self.destination)

    def message(self, m):
        # 		print "Sending: " + repr(m)
        message = self.session.createTextMessage(m)
        self.producer.send(message)

    def close(self):
        try:
            self.connection.close()
        except:
            pass
Example #5
0
# disclosed, or represents that its use would not infringe privately owned rights.
# 
# Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, 
# or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United 
# States Government or any agency thereof, or Battelle Memorial Institute. The views and opinions of authors expressed 
# herein do not necessarily state or reflect those of the United States Government or any agency thereof.
# 
# PACIFIC NORTHWEST NATIONAL LABORATORY operated by BATTELLE for the 
# UNITED STATES DEPARTMENT OF ENERGY under Contract DE-AC05-76RL01830
#-------------------------------------------------------------------------------
from javax.jms import Session

 
from org.apache.activemq import ActiveMQConnectionFactory
 
connFactory = ActiveMQConnectionFactory()
 
conn = connFactory.createConnection()
 
sess = conn.createSession(False, Session.AUTO_ACKNOWLEDGE)
 
dest = sess.createTopic('SampleTopic')
 
cons = sess.createConsumer(dest)
 
conn.start()
 
msg = cons.receive()
 
print(msg)