org.apache.activemq.ActiveMQConnectionFactory Java Examples

The following examples show how to use org.apache.activemq.ActiveMQConnectionFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScannerBuildListener.java    From repairnator with MIT License 6 votes vote down vote up
public void runListenerServer() {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(config.getActiveMQUrl() + "?jms.prefetchPolicy.all=1");
    Connection connection;
    try {
        connection = connectionFactory.createConnection();
        connection.start();
        Session session = connection.createSession(false,Session.CLIENT_ACKNOWLEDGE);
        Destination queue = session.createQueue(config.getActiveMQListenQueueName());

        MessageConsumer consumer = session.createConsumer(queue);
        consumer.setMessageListener(this);
        LOGGER.warn("Server is now listening for build ids");
    } catch (JMSException e) {
        throw new RuntimeException(e);
    }
}
 
Example #2
Source File: CaseController.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    Session session = null;
    Connection connection = null;
    try {
        ConnectionFactory factory = new ActiveMQConnectionFactory(USER_NAME, PASSWORD, brokenUrl);
        connection = factory.createConnection();
        connection.start();
        session = connection.createSession(Boolean.TRUE, Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createQueue("test");
        MessageConsumer messageConsumer = session.createConsumer(destination);
        messageConsumer.receive();
        session.close();
        connection.close();
    } catch (Exception ex) {
        logger.error(ex);
        try {
            session.close();
            connection.close();
        } catch (JMSException e) {
            logger.error(e);
        }
    }
}
 
Example #3
Source File: TopicBridgeStandaloneReconnectTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

   localConnectionFactory = createLocalConnectionFactory();
   foreignConnectionFactory = createForeignConnectionFactory();

   outbound = new ActiveMQTopic("RECONNECT.TEST.OUT.TOPIC");
   inbound = new ActiveMQTopic("RECONNECT.TEST.IN.TOPIC");

   jmsTopicConnector = new SimpleJmsTopicConnector();

   // Wire the bridges.
   jmsTopicConnector.setOutboundTopicBridges(new OutboundTopicBridge[]{new OutboundTopicBridge("RECONNECT.TEST.OUT.TOPIC")});
   jmsTopicConnector.setInboundTopicBridges(new InboundTopicBridge[]{new InboundTopicBridge("RECONNECT.TEST.IN.TOPIC")});

   // Tell it how to reach the two brokers.
   jmsTopicConnector.setOutboundTopicConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61617"));
   jmsTopicConnector.setLocalTopicConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61616"));
}
 
Example #4
Source File: JmsPluginIT.java    From glowroot with Apache License 2.0 6 votes vote down vote up
@Override
public void executeApp() throws Exception {
    ConnectionFactory connectionFactory =
            new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
    Connection connection = connectionFactory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = session.createQueue("a queue");
    MessageConsumer consumer = session.createConsumer(queue);
    consumer.setMessageListener(new TestMessageListener());
    MessageProducer producer = session.createProducer(queue);
    Message message = session.createMessage();
    producer.send(message);
    SECONDS.sleep(1);
    connection.close();
}
 
Example #5
Source File: QueueBrowsingTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Before
public void startBroker() throws Exception {
   broker = createBroker();
   TransportConnector connector = broker.addConnector("tcp://0.0.0.0:0");
   broker.deleteAllMessages();
   broker.start();
   broker.waitUntilStarted();

   PolicyEntry policy = new PolicyEntry();
   policy.setMaxPageSize(maxPageSize);
   broker.setDestinationPolicy(new PolicyMap());
   broker.getDestinationPolicy().setDefaultEntry(policy);

   connectUri = connector.getConnectUri();
   factory = new ActiveMQConnectionFactory(connectUri);
}
 
Example #6
Source File: NetworkLoadTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected Connection createConnection(int brokerId) throws JMSException {
   ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:" + (60000 + brokerId));
   connectionFactory.setOptimizedMessageDispatch(true);
   connectionFactory.setCopyMessageOnSend(false);
   connectionFactory.setUseCompression(false);
   connectionFactory.setDispatchAsync(true);
   connectionFactory.setUseAsyncSend(false);
   connectionFactory.setOptimizeAcknowledge(false);
   connectionFactory.setWatchTopicAdvisories(false);
   ActiveMQPrefetchPolicy qPrefetchPolicy = new ActiveMQPrefetchPolicy();
   qPrefetchPolicy.setQueuePrefetch(100);
   qPrefetchPolicy.setTopicPrefetch(1000);
   connectionFactory.setPrefetchPolicy(qPrefetchPolicy);
   connectionFactory.setAlwaysSyncSend(true);
   return connectionFactory.createConnection();
}
 
Example #7
Source File: Publisher.java    From jms with MIT License 6 votes vote down vote up
public void create(String clientId, String topicName)
    throws JMSException {
  this.clientId = clientId;

  // create a Connection Factory
  ConnectionFactory connectionFactory =
      new ActiveMQConnectionFactory(
          ActiveMQConnection.DEFAULT_BROKER_URL);

  // create a Connection
  connection = connectionFactory.createConnection();
  connection.setClientID(clientId);

  // create a Session
  session =
      connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

  // create the Topic to which messages will be sent
  Topic topic = session.createTopic(topicName);

  // create a MessageProducer for sending messages
  messageProducer = session.createProducer(topic);
}
 
Example #8
Source File: FailoverTimeoutTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateUris() throws Exception {

   ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + tcpUri + ")?useExponentialBackOff=false");
   ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
   try {
      connection.start();
      FailoverTransport failoverTransport = connection.getTransport().narrow(FailoverTransport.class);

      URI[] bunchOfUnknownAndOneKnown = new URI[]{new URI("tcp://unknownHost:" + tcpUri.getPort()), new URI("tcp://unknownHost2:" + tcpUri.getPort()), new URI("tcp://localhost:2222")};
      failoverTransport.add(false, bunchOfUnknownAndOneKnown);
   } finally {
      if (connection != null) {
         connection.close();
      }
   }
}
 
Example #9
Source File: FtpToJMSWithPropertyPlaceholderTest.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
protected CamelContext createCamelContext() throws Exception {
    // create CamelContext
    CamelContext camelContext = super.createCamelContext();
    
    // connect to embedded ActiveMQ JMS broker
    ConnectionFactory connectionFactory = 
        new ActiveMQConnectionFactory("vm://localhost");
    camelContext.addComponent("jms",
        JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));

    // setup the properties component to use the test file
    PropertiesComponent prop = camelContext.getComponent("properties", PropertiesComponent.class);
    prop.setLocation("classpath:rider-test.properties");        
    
    return camelContext;
}
 
Example #10
Source File: AMQSinkTest.java    From bahir-flink with Apache License 2.0 6 votes vote down vote up
@BeforeEach
public void before() throws Exception {
    connectionFactory = mock(ActiveMQConnectionFactory.class);
    producer = mock(MessageProducer.class);
    session = mock(Session.class);
    connection = mock(Connection.class);
    destination = mock(Destination.class);
    message = mock(BytesMessage.class);

    when(connectionFactory.createConnection()).thenReturn(connection);
    when(connection.createSession(anyBoolean(), anyInt())).thenReturn(session);
    when(session.createProducer(null)).thenReturn(producer);
    when(session.createBytesMessage()).thenReturn(message);
    serializationSchema = new SimpleStringSchema();

    AMQSinkConfig<String> config = new AMQSinkConfig.AMQSinkConfigBuilder<String>()
        .setConnectionFactory(connectionFactory)
        .setDestinationName(DESTINATION_NAME)
        .setSerializationSchema(serializationSchema)
        .build();
    amqSink = new AMQSink<>(config);
    amqSink.open(new Configuration());
}
 
Example #11
Source File: ConnectorXBeanConfigTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public void testForceBrokerRestart() throws Exception {
   brokerService.stop();
   brokerService.waitUntilStopped();

   brokerService.start(true); // force restart
   brokerService.waitUntilStarted();

   LOG.info("try and connect to restarted broker");
   //send and receive a message from a restarted broker
   ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61636");
   Connection conn = factory.createConnection();
   Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
   conn.start();
   Destination dest = new ActiveMQQueue("test");
   MessageConsumer consumer = sess.createConsumer(dest);
   MessageProducer producer = sess.createProducer(dest);
   producer.send(sess.createTextMessage("test"));
   TextMessage msg = (TextMessage) consumer.receive(1000);
   assertEquals("test", msg.getText());
}
 
Example #12
Source File: MessageSender.java    From AuTe-Framework with Apache License 2.0 5 votes vote down vote up
private void sendActiveMq(String queue, String text) throws JMSException {
  ConnectionFactory factory = new ActiveMQConnectionFactory(
      properties.getUsername(),
      properties.getPassword(),
      String.format("tcp://%s:%d", properties.getHost(), properties.getPort())
  );
  sendJms(queue, text, factory);
}
 
Example #13
Source File: JmsFactory.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public static ConnectionFactory createConnectionFactory(final String url, final int timeoutMillis, final String jmsProvider) throws JMSException {
    switch (jmsProvider) {
        case ACTIVEMQ_PROVIDER: {
            final ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url);
            factory.setSendTimeout(timeoutMillis);
            return factory;
        }
        default:
            throw new IllegalArgumentException("Unknown JMS Provider: " + jmsProvider);
    }
}
 
Example #14
Source File: PublishJMSTest.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void validateSuccessfulPublishAndTransferToSuccess() throws Exception {
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");

    final String destinationName = "fooQueue";
    PublishJMS pubProc = new PublishJMS();
    TestRunner runner = TestRunners.newTestRunner(pubProc);
    JMSConnectionFactoryProviderDefinition cs = mock(JMSConnectionFactoryProviderDefinition.class);
    when(cs.getIdentifier()).thenReturn("cfProvider");
    when(cs.getConnectionFactory()).thenReturn(cf);

    runner.addControllerService("cfProvider", cs);
    runner.enableControllerService(cs);

    runner.setProperty(PublishJMS.CF_SERVICE, "cfProvider");
    runner.setProperty(PublishJMS.DESTINATION, destinationName);

    Map<String, String> attributes = new HashMap<>();
    attributes.put("foo", "foo");
    attributes.put(JmsHeaders.REPLY_TO, "cooQueue");
    runner.enqueue("Hey dude!".getBytes(), attributes);
    runner.run(1, false);

    final MockFlowFile successFF = runner.getFlowFilesForRelationship(PublishJMS.REL_SUCCESS).get(0);
    assertNotNull(successFF);

    JmsTemplate jmst = new JmsTemplate(cf);
    BytesMessage message = (BytesMessage) jmst.receive(destinationName);

    byte[] messageBytes = MessageBodyToBytesConverter.toBytes(message);
    assertEquals("Hey dude!", new String(messageBytes));
    assertEquals("cooQueue", ((Queue) message.getJMSReplyTo()).getQueueName());
    assertEquals("foo", message.getStringProperty("foo"));
}
 
Example #15
Source File: JMSHelloWorld.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
public void run() {
	try {

		// Create a ConnectionFactory
		ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");

		// Create a Connection
		Connection connection = connectionFactory.createConnection();
		connection.start();

		connection.setExceptionListener(this);

		// Create a Session
		Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

		// Create the destination (Topic or Queue)
		Destination destination = session.createQueue("TEST.FOO");

		// Create a MessageConsumer from the Session to the Topic or Queue
		MessageConsumer consumer = session.createConsumer(destination);

		// Wait for a message
		Message message = consumer.receive(1000);

		if (message instanceof TextMessage) {
			TextMessage textMessage = (TextMessage) message;
			String text = textMessage.getText();
			System.out.println("Received: " + text);
		} else {
			System.out.println("Received: " + message);
		}

		consumer.close();
		session.close();
		connection.close();
	} catch (Exception e) {
		System.out.println("Caught: " + e);
		e.printStackTrace();
	}
}
 
Example #16
Source File: NIOSSLWindowSizeTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
   System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE);
   System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD);
   System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE);
   System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE);
   System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE);
   System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD);

   broker = new BrokerService();
   broker.setPersistent(false);
   broker.setUseJmx(false);
   TransportConnector connector = broker.addConnector("nio+ssl://localhost:0?transport.needClientAuth=true");
   broker.start();
   broker.waitUntilStarted();

   messageData = new byte[MESSAGE_SIZE];
   for (int i = 0; i < MESSAGE_SIZE; i++) {
      messageData[i] = (byte) (i & 0xff);
   }

   ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("nio+ssl://localhost:" + connector.getConnectUri().getPort());
   connection = factory.createConnection();
   session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   connection.start();
}
 
Example #17
Source File: BrokerStatisticsPluginTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
   broker = createBroker();
   ConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectorURIsAsMap().get("tcp"));
   connection = factory.createConnection();
   connection.start();
}
 
Example #18
Source File: OrderRouterWithWireTap.java    From camelinaction with Apache License 2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    // create CamelContext
    CamelContext context = new DefaultCamelContext();
    
    // connect to embedded ActiveMQ JMS broker
    ConnectionFactory connectionFactory = 
        new ActiveMQConnectionFactory("vm://localhost");
    context.addComponent("jms",
        JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));

    // add our route to the CamelContext
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() {
            // load file orders from src/data into the JMS queue
            from("file:src/data?noop=true").to("jms:incomingOrders");
    
            // content-based router
            from("jms:incomingOrders")
            .wireTap("jms:orderAudit")
            .choice()
                .when(header("CamelFileName").endsWith(".xml"))
                    .to("jms:xmlOrders")  
                .when(header("CamelFileName").regex("^.*(csv|csl)$"))
                    .to("jms:csvOrders")
                .otherwise()
                    .to("jms:badOrders");                    
        }
    });

    // start the route and let it do its work
    context.start();
    Thread.sleep(2000);

    // stop the CamelContext
    context.stop();
}
 
Example #19
Source File: JNDITestSupport.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Stops all existing ActiveMQConnectionFactory in Context.
 *
 * @throws javax.naming.NamingException
 */
@Override
protected void tearDown() throws NamingException, JMSException {
   NamingEnumeration<Binding> iter = context.listBindings("");
   while (iter.hasMore()) {
      Binding binding = iter.next();
      Object connFactory = binding.getObject();
      if (connFactory instanceof ActiveMQConnectionFactory) {
         // ((ActiveMQConnectionFactory) connFactory).stop();
      }
   }
}
 
Example #20
Source File: InitConfServer.java    From blog with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 创建jms连接
 * 
 * @return
 * @throws JMSException
 */
private QueueConnection createSharedConnection() throws JMSException {
	ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(MQADDRESS);
	QueueConnection connection = null;
	try {
		connection = factory.createQueueConnection();
	} catch (JMSException e) {
		closeConnection(connection);
		throw e;
	}
	return connection;
}
 
Example #21
Source File: OrderRouterWithFilterTest.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
@Override
protected CamelContext createCamelContext() throws Exception {
    // create CamelContext
    CamelContext camelContext = super.createCamelContext();
    
    // connect to embedded ActiveMQ JMS broker
    ConnectionFactory connectionFactory = 
        new ActiveMQConnectionFactory("vm://localhost");
    camelContext.addComponent("jms",
        JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
    
    return camelContext;
}
 
Example #22
Source File: ITActiveMQSender.java    From zipkin-reporter-java with Apache License 2.0 5 votes vote down vote up
@Test public void checkFalseWhenBrokerIsDown() throws IOException {
  sender.close();
  ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
  // we can be pretty certain ActiveMQ isn't running on localhost port 80
  connectionFactory.setBrokerURL("tcp://localhost:80");
  sender = builder().connectionFactory(connectionFactory).build();

  CheckResult check = sender.check();
  assertThat(check.ok()).isFalse();
  assertThat(check.error()).isInstanceOf(IOException.class);
}
 
Example #23
Source File: DurableSubscriptionHangTestCase.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void registerDurableSubscription() throws JMSException {
   ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + brokerName);
   TopicConnection connection = connectionFactory.createTopicConnection();
   connection.setClientID(clientID);
   TopicSession topicSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
   Topic topic = topicSession.createTopic(topicName);
   TopicSubscriber durableSubscriber = topicSession.createDurableSubscriber(topic, durableSubName);
   connection.start();
   durableSubscriber.close();
   connection.close();
   LOG.info("Durable Sub Registered");
}
 
Example #24
Source File: MockServerConfig.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public MessageListenerContainer mockServerListener(ActiveMQConnectionFactory connectionFactory) {
  DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
  container.setConnectionFactory(connectionFactory);
  container.setDestination(new ActiveMQQueue("c2mon.client.request"));
  container.setMessageListener((SessionAwareMessageListener) (message, session) -> {
    session.createProducer(message.getJMSReplyTo()).send(session.createTextMessage("[]"));
  });
  return container;
}
 
Example #25
Source File: ActiveMQMailQueueFactoryTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp(BrokerService brokerService) {
    fileSystem = new ActiveMQMailQueueBlobTest.MyFileSystem();
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?create=false");


    FileSystemBlobTransferPolicy policy = new FileSystemBlobTransferPolicy();
    policy.setFileSystem(fileSystem);
    policy.setDefaultUploadUrl(BASE_DIR);
    connectionFactory.setBlobTransferPolicy(policy);

    RawMailQueueItemDecoratorFactory mailQueueItemDecoratorFactory = new RawMailQueueItemDecoratorFactory();
    RecordingMetricFactory metricFactory = new RecordingMetricFactory();
    NoopGaugeRegistry gaugeRegistry = new NoopGaugeRegistry();
    mailQueueFactory = new ActiveMQMailQueueFactory(connectionFactory, mailQueueItemDecoratorFactory, metricFactory, gaugeRegistry);
    mailQueueFactory.setUseJMX(false);
    mailQueueFactory.setUseBlobMessages(true);
}
 
Example #26
Source File: OrderRouterWithRecipientListTest.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
@Override
protected CamelContext createCamelContext() throws Exception {
    // create CamelContext
    CamelContext camelContext = super.createCamelContext();
    
    // connect to embedded ActiveMQ JMS broker
    ConnectionFactory connectionFactory = 
        new ActiveMQConnectionFactory("vm://localhost");
    camelContext.addComponent("jms",
        JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
    
    return camelContext;
}
 
Example #27
Source File: OpenTypeSupportTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
   brokerService = new BrokerService();
   brokerService.setPersistent(false);
   brokerService.setUseJmx(true);
   connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
   brokerService.start();
   connectionFactory = new ActiveMQConnectionFactory(connectionUri);
   sendMessage();
}
 
Example #28
Source File: KahaDBSchedulerMissingJournalLogsTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void fillUpSomeLogFiles() throws Exception {
   ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
   Connection connection = cf.createConnection();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Queue queue = session.createQueue("test.queue");
   MessageProducer producer = session.createProducer(queue);
   connection.start();
   while (true) {
      scheduleRepeating(session, producer);
      if (schedulerStore.getJournal().getFileMap().size() == NUM_LOGS) {
         break;
      }
   }
   connection.close();
}
 
Example #29
Source File: ReceiverConfig.java    From spring-jms with MIT License 5 votes vote down vote up
@Bean
public ActiveMQConnectionFactory receiverActiveMQConnectionFactory() {
  ActiveMQConnectionFactory activeMQConnectionFactory =
      new ActiveMQConnectionFactory();
  activeMQConnectionFactory.setBrokerURL(brokerUrl);

  return activeMQConnectionFactory;
}
 
Example #30
Source File: MessageCompressionTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private ActiveMQBytesMessage receiveTestBytesMessage(ActiveMQConnectionFactory factory) throws JMSException, UnsupportedEncodingException {
   ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
   connection.start();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageConsumer consumer = session.createConsumer(queue);
   ActiveMQBytesMessage rc = (ActiveMQBytesMessage) consumer.receive();
   connection.close();
   return rc;
}