[ 
https://issues.apache.org/jira/browse/ARTEMIS-2919?focusedWorklogId=608078&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-608078
 ]

ASF GitHub Bot logged work on ARTEMIS-2919:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Jun/21 19:33
            Start Date: 07/Jun/21 19:33
    Worklog Time Spent: 10m 
      Work Description: jbertram commented on a change in pull request #3279:
URL: https://github.com/apache/activemq-artemis/pull/3279#discussion_r646883610



##########
File path: 
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IngressTimeTest.java
##########
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.client;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.QueueConfiguration;
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.qpid.jms.JmsConnectionFactory;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class IngressTimeTest extends ActiveMQTestBase {
+   private ActiveMQServer server;
+
+   private final SimpleString QUEUE = new SimpleString("ConsumerTestQueue");
+
+   @Before
+   @Override
+   public void setUp() throws Exception {
+      super.setUp();
+      server = createServer(true, true);
+      server.start();
+      server.getAddressSettingsRepository().addMatch("#", new 
AddressSettings().setEnableIngressTime(true));
+      server.createQueue(new 
QueueConfiguration(QUEUE).setRoutingType(RoutingType.ANYCAST));
+   }
+
+   @Test
+   public void testSendCoreReceiveCore() throws Throwable {
+      internalSendReceive(Protocol.CORE, Protocol.CORE);
+   }
+
+   @Test
+   public void testSendAMQPReceiveCore() throws Throwable {
+      internalSendReceive(Protocol.AMQP, Protocol.CORE);
+   }
+
+   @Test
+   public void testSendOpenWireReceiveCore() throws Throwable {
+      internalSendReceive(Protocol.OPENWIRE, Protocol.CORE);
+   }
+
+   @Test
+   public void testSendCoreReceiveOpenwire() throws Throwable {
+      internalSendReceive(Protocol.CORE, Protocol.OPENWIRE);
+   }
+
+   @Test
+   public void testSendAMQPReceiveOpenWire() throws Throwable {
+      internalSendReceive(Protocol.AMQP, Protocol.OPENWIRE);
+   }
+
+   @Test
+   public void testSendOpenWireReceiveOpenWire() throws Throwable {
+      internalSendReceive(Protocol.OPENWIRE, Protocol.OPENWIRE);
+   }
+
+   /**
+    *  AMQP receiver tests are in 
org.apache.activemq.artemis.tests.integration.amqp.AmqpIngressTimeTest
+    */
+
+   private void internalSendReceive(Protocol protocolSender, Protocol 
protocolConsumer) throws Throwable {
+      ConnectionFactory factorySend = createFactory(protocolSender);
+      ConnectionFactory factoryConsume = protocolConsumer == protocolSender ? 
factorySend : createFactory(protocolConsumer);
+
+      long beforeSend, afterSend;
+      try (Connection connection = factorySend.createConnection()) {
+         try (Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE)) {
+            javax.jms.Queue queue = session.createQueue(QUEUE.toString());
+            try (MessageProducer producer = session.createProducer(queue)) {
+               producer.setDeliveryMode(DeliveryMode.PERSISTENT);
+               TextMessage msg = session.createTextMessage("hello");
+               beforeSend = System.currentTimeMillis();
+               producer.send(msg);
+               afterSend = System.currentTimeMillis();
+            }
+         }
+      }
+
+      server.stop();
+      server.start();
+      assertTrue(server.waitForActivation(3, TimeUnit.SECONDS));
+
+      try (Connection connection = factoryConsume.createConnection()) {
+         connection.start();
+         try (Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE)) {
+            javax.jms.Queue queue = session.createQueue(QUEUE.toString());
+            try (MessageConsumer consumer = session.createConsumer(queue)) {
+               TextMessage message = (TextMessage) consumer.receive(1000);
+               Assert.assertNotNull(message);
+               Object ingressTime = 
message.getObjectProperty(Message.HDR_INGRESS_TIME.toString());
+               assertNotNull(ingressTime);
+               assertTrue(ingressTime instanceof Long);
+               long ingress = (Long) ingressTime;
+               assertTrue("Ingress time should be set in expected 
range",beforeSend <= ingress && afterSend >= ingress);

Review comment:
       Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 608078)
    Time Spent: 7h 40m  (was: 7.5h)

> Support timestamping incoming messages
> --------------------------------------
>
>                 Key: ARTEMIS-2919
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2919
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>            Reporter: Justin Bertram
>            Assignee: Justin Bertram
>            Priority: Major
>          Time Spent: 7h 40m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to