Codota Logo
TextMessage.getJMSTimestamp
Code IndexAdd Codota 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)

  • Common ways to obtain TextMessage
private void myMethod () {
TextMessage t =
  • Codota IconSession session;String text;session.createTextMessage(text)
  • Codota IconSession session;session.createTextMessage()
  • Codota IconQueueSession senderSession;senderSession.createTextMessage()
  • Smart code suggestions by Codota
}
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

  • Parsing JSON documents to java classes using gson
  • setContentView (Activity)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • HashSet (java.util)
    This class implements the Set interface, backed by a hash table (actually a HashMap instance). It m
  • LinkedHashMap (java.util)
    Hash table and linked list implementation of the Map interface, with predictable iteration order. Th
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now