Tabnine Logo
TextMessage.getJMSTimestamp
Code IndexAdd Tabnine to your IDE (free)

How to use
getJMSTimestamp
method
in
javax.jms.TextMessage

Best Java code snippets using javax.jms.TextMessage.getJMSTimestamp (Showing top 15 results out of 315)

origin: apache/activemq-artemis

@Test
public void testJMSTimestampOnSelector() throws Exception {
 Connection conn = null;
 try {
   conn = getConnectionFactory().createConnection();
   conn.start();
   Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageProducer prod = session.createProducer(queue1);
   TextMessage msg1 = session.createTextMessage("msg1");
   prod.send(msg1);
   Thread.sleep(2);
   TextMessage msg2 = session.createTextMessage("msg2");
   prod.send(msg2);
   String selector = "JMSTimestamp = " + msg2.getJMSTimestamp();
   MessageConsumer cons = session.createConsumer(queue1, selector);
   conn.start();
   TextMessage rec = (TextMessage) cons.receive(10000);
   assertNotNull(rec);
   Assert.assertEquals("msg2", rec.getText());
   assertNull(cons.receiveNoWait());
 } finally {
   if (conn != null) {
    conn.close();
   }
 }
}
origin: org.apache.beam/beam-sdks-java-io-jms

 @Override
 public JmsRecord mapMessage(Message message) throws Exception {
  TextMessage textMessage = (TextMessage) message;
  Map<String, Object> properties = new HashMap<>();
  @SuppressWarnings("rawtypes")
  Enumeration propertyNames = textMessage.getPropertyNames();
  while (propertyNames.hasMoreElements()) {
   String propertyName = (String) propertyNames.nextElement();
   properties.put(propertyName, textMessage.getObjectProperty(propertyName));
  }
  JmsRecord jmsRecord =
    new JmsRecord(
      textMessage.getJMSMessageID(),
      textMessage.getJMSTimestamp(),
      textMessage.getJMSCorrelationID(),
      textMessage.getJMSReplyTo(),
      textMessage.getJMSDestination(),
      textMessage.getJMSDeliveryMode(),
      textMessage.getJMSRedelivered(),
      textMessage.getJMSType(),
      textMessage.getJMSExpiration(),
      textMessage.getJMSPriority(),
      properties,
      textMessage.getText());
  return jmsRecord;
 }
})
origin: apache/activemq-artemis

@Test
public void testSendMessageWithReceipt() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue);
 conn.connect(defUser, defPass);
 send(conn, getQueuePrefix() + getQueueName(), null, "Hello World", true);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // Make sure that the timestamp is valid - should
 // be very close to the current time.
 long tnow = System.currentTimeMillis();
 long tmsg = message.getJMSTimestamp();
 Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
}
origin: apache/activemq-artemis

@Test(timeout = 30000)
public void testSelectorsWithJMSTimestampOnQueue() throws Exception {
 final Connection connection = createConnection();
 try {
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Destination destination = session.createQueue(getQueueName());
   MessageProducer producer = session.createProducer(destination);
   TextMessage message1 = session.createTextMessage();
   message1.setText("filtered");
   producer.send(message1, DeliveryMode.PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
   // short delay to prevent the timestamps from being the same
   Thread.sleep(2);
   TextMessage message2 = session.createTextMessage();
   message2.setText("expected");
   producer.send(message2, DeliveryMode.PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
   MessageConsumer consumer = session.createConsumer(destination, "JMSTimestamp = " + message2.getJMSTimestamp());
   connection.start();
   Message msg = consumer.receive(2000);
   assertNotNull(msg);
   assertTrue(msg instanceof TextMessage);
   assertEquals("Unexpected JMSTimestamp value", message2.getJMSTimestamp(), msg.getJMSTimestamp());
   assertEquals("Unexpected message content", "expected", ((TextMessage) msg).getText());
 } finally {
   connection.close();
 }
}
origin: apache/activemq-artemis

@Test
public void testSendMessageWithReceipt() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue);
 conn.connect(defUser, defPass);
 send(conn, getQueuePrefix() + getQueueName(), null, "Hello World", true);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // Make sure that the timestamp is valid - should
 // be very close to the current time.
 long tnow = System.currentTimeMillis();
 long tmsg = message.getJMSTimestamp();
 Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
 conn.disconnect();
}
origin: apache/activemq-artemis

@Test
public void testSendMessageWithReceipt() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue);
 conn.connect(defUser, defPass);
 send(conn, getQueuePrefix() + getQueueName(), null, "Hello World", true);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // Make sure that the timestamp is valid - should
 // be very close to the current time.
 long tnow = System.currentTimeMillis();
 long tmsg = message.getJMSTimestamp();
 Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
 conn.disconnect();
}
origin: apache/activemq-artemis

@Test
public void testSendMessage() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue);
 conn.connect(defUser, defPass);
 send(conn, getQueuePrefix() + getQueueName(), null, "Hello World");
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // Assert default priority 4 is used when priority header is not set
 Assert.assertEquals("getJMSPriority", 4, message.getJMSPriority());
 // Make sure that the timestamp is valid - should
 // be very close to the current time.
 long tnow = System.currentTimeMillis();
 long tmsg = message.getJMSTimestamp();
 Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
}
origin: apache/activemq-artemis

@Test
public void testSendMessage() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue);
 conn.connect(defUser, defPass);
 send(conn, getQueuePrefix() + getQueueName(), null, "Hello World");
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // Assert default priority 4 is used when priority header is not set
 Assert.assertEquals("getJMSPriority", 4, message.getJMSPriority());
 // Make sure that the timestamp is valid - should
 // be very close to the current time.
 long tnow = System.currentTimeMillis();
 long tmsg = message.getJMSTimestamp();
 Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
}
origin: apache/activemq-artemis

@Test
public void testSendMessage() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue);
 conn.connect(defUser, defPass);
 send(conn, getQueuePrefix() + getQueueName(), null, "Hello World");
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // Assert default priority 4 is used when priority header is not set
 Assert.assertEquals("getJMSPriority", 4, message.getJMSPriority());
 // Make sure that the timestamp is valid - should
 // be very close to the current time.
 long tnow = System.currentTimeMillis();
 long tmsg = message.getJMSTimestamp();
 Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
}
origin: apache/activemq-artemis

@Test
public void testSendMessageWithLeadingNewLine() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue);
 Thread.sleep(1000);
 conn.connect(defUser, defPass);
 ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND)
                .addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName())
                .setBody("Hello World");
 conn.sendWickedFrame(frame);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // Make sure that the timestamp is valid - should
 // be very close to the current time.
 long tnow = System.currentTimeMillis();
 long tmsg = message.getJMSTimestamp();
 Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
 assertNull(consumer.receive(1000));
 conn.disconnect();
}
origin: apache/activemq-artemis

@Test
public void testSendMessageWithLeadingNewLine() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue);
 conn.connect(defUser, defPass);
 ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND)
                .addHeader(Stomp.Headers.Subscribe.DESTINATION, getQueuePrefix() + getQueueName())
                .setBody("Hello World");
 conn.sendWickedFrame(frame);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // Make sure that the timestamp is valid - should
 // be very close to the current time.
 long tnow = System.currentTimeMillis();
 long tmsg = message.getJMSTimestamp();
 Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
 Assert.assertNull(consumer.receive(1000));
 conn.disconnect();
}
origin: apache/activemq-artemis

@Test
public void testSendMessageWithLeadingNewLine() throws Exception {
 conn.connect(defUser, defPass);
 ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND)
                .addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName())
                .setBody("Hello World");
 conn.sendWickedFrame(frame);
 MessageConsumer consumer = session.createConsumer(queue);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 send(conn, getQueuePrefix() + getQueueName(), null, "Hello World");
 message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // Make sure that the timestamp is valid - should
 // be very close to the current time.
 long tnow = System.currentTimeMillis();
 long tmsg = message.getJMSTimestamp();
 Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
}
origin: apache/activemq-artemis

public void sendMessageToNonExistentTopic(String topicPrefix, String topic, RoutingType routingType) throws Exception {
 conn.connect(defUser, defPass);
 // first send a message to ensure that sending to a non-existent topic won't throw an error
 send(conn, topicPrefix + topic, null, "Hello World", true, routingType);
 // create a subscription on the topic and send/receive another message
 MessageConsumer consumer = session.createConsumer(ActiveMQJMSClient.createTopic(topic));
 send(conn, topicPrefix + topic, null, "Hello World", true, routingType);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // Assert default priority 4 is used when priority header is not set
 Assert.assertEquals("getJMSPriority", 4, message.getJMSPriority());
 // Make sure that the timestamp is valid - should
 // be very close to the current time.
 long tnow = System.currentTimeMillis();
 long tmsg = message.getJMSTimestamp();
 Assert.assertTrue(Math.abs(tnow - tmsg) < 1500);
 assertNotNull(server.getAddressInfo(new SimpleString(topic)));
 // closing the consumer here should trigger auto-deletion of the subscription queue and address
 consumer.close();
 Thread.sleep(200);
 assertNull(server.getAddressInfo(new SimpleString(topic)));
}
origin: apache/activemq-artemis

public void sendMessageToNonExistentQueue(String queuePrefix, String queue, RoutingType routingType) throws Exception {
 conn.connect(defUser, defPass);
 send(conn, queuePrefix + queue, null, "Hello World", true, routingType);
 MessageConsumer consumer = session.createConsumer(ActiveMQJMSClient.createQueue(queue));
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // Assert default priority 4 is used when priority header is not set
 Assert.assertEquals("getJMSPriority", 4, message.getJMSPriority());
 // Make sure that the timestamp is valid - should
 // be very close to the current time.
 long tnow = System.currentTimeMillis();
 long tmsg = message.getJMSTimestamp();
 Assert.assertTrue(Math.abs(tnow - tmsg) < 1500);
 // closing the consumer here should trigger auto-deletion
 assertNotNull(server.getPostOffice().getBinding(new SimpleString(queue)));
 consumer.close();
 assertNull(server.getPostOffice().getBinding(new SimpleString(queue)));
}
origin: apache/activemq-artemis

  @Test
  public void testJMSXUserID() throws Exception {
   server.getConfiguration().setPopulateValidatedUser(true);

   MessageConsumer consumer = session.createConsumer(queue);

   StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
   conn.connect(defUser, defPass);

   ClientStompFrame frame = conn.createFrame("SEND");
   frame.addHeader("destination", getQueuePrefix() + getQueueName());
   frame.setBody("Hello World");
   conn.sendFrame(frame);

   conn.disconnect();

   TextMessage message = (TextMessage) consumer.receive(1000);
   Assert.assertNotNull(message);
   Assert.assertEquals("Hello World", message.getText());
   // Assert default priority 4 is used when priority header is not set
   Assert.assertEquals("getJMSPriority", 4, message.getJMSPriority());
   Assert.assertEquals("JMSXUserID", "brianm", message.getStringProperty("JMSXUserID"));

   // Make sure that the timestamp is valid - should
   // be very close to the current time.
   long tnow = System.currentTimeMillis();
   long tmsg = message.getJMSTimestamp();
   Assert.assertTrue(Math.abs(tnow - tmsg) < 1000);
  }
}
javax.jmsTextMessagegetJMSTimestamp

Popular methods of TextMessage

  • getText
    Gets the string containing this message's data. The default value is null.
  • setText
    Sets the string containing this message's data.
  • setStringProperty
  • setJMSCorrelationID
  • setIntProperty
  • setLongProperty
  • getStringProperty
  • setBooleanProperty
  • setJMSReplyTo
  • getJMSCorrelationID
  • getJMSMessageID
  • getJMSReplyTo
  • getJMSMessageID,
  • getJMSReplyTo,
  • setDoubleProperty,
  • acknowledge,
  • setJMSType,
  • getJMSDeliveryMode,
  • setObjectProperty,
  • getIntProperty,
  • getJMSPriority,
  • clearBody

Popular in Java

  • Making http post requests using okhttp
  • putExtra (Intent)
  • runOnUiThread (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • String (java.lang)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now