[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=805756=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-805756 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 02/Sep/22 13:21 Start Date: 02/Sep/22 13:21 Worklog Time Spent: 10m Work Description: mattrpav merged PR #729: URL: https://github.com/apache/activemq/pull/729 Issue Time Tracking --- Worklog Id: (was: 805756) Time Spent: 17h 20m (was: 17h 10m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 17h 20m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=805755=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-805755 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 02/Sep/22 13:19 Start Date: 02/Sep/22 13:19 Worklog Time Spent: 10m Work Description: mattrpav commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1235497535 Sounds good. Merging this now and then will get started on the next round of features. Issue Time Tracking --- Worklog Id: (was: 805755) Time Spent: 17h 10m (was: 17h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 17h 10m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=805213=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-805213 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 31/Aug/22 12:43 Start Date: 31/Aug/22 12:43 Worklog Time Spent: 10m Work Description: cshannon commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1232889253 @gemmellr - Yeah, this could be merged as is and then add a follow on PR for getBody, isBodyssignable and JMSConsumer receive body. I think those should be implemented for 5.18 as no reason not to really but as you said this PR has been open for 9 months so it's time to merge it. And your comment about the "alpha" thing is what I was getting at with my comment about communication to users. Not sure the best way to describe it but we need to make it clear this is not fully implemented and kind of a preview or alpha/beta of JMS 2.0 changes or however we want to call it. Issue Time Tracking --- Worklog Id: (was: 805213) Time Spent: 17h (was: 16h 50m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 17h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=805205=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-805205 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 31/Aug/22 12:16 Start Date: 31/Aug/22 12:16 Worklog Time Spent: 10m Work Description: gemmellr commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1232859161 Not implementing the Message getBody and isBodyAssignableTo bits, and also the JMSConsumer 'recieve body' behaviour when the JMSProducer side 'send ' equivalent _is_ implemented, does seem quite odd. But then to me personally so does the idea of releasing anything not considered e.g. an alpha, without so many basic new APIs and most of the core JMS 2 behavioural additions yet being implemented. Merging may still make sense, it has been open for 9 months already and it is after all considered a first-pass...but releasing it isnt really making much more to me now than it did when 5.17.0 was being prepared 6 months ago; it hasnt really substantially changed since then. I'll be leaving further review to others, e.g JB was keen to implement it originally and tends to work on the 5.x releases. Issue Time Tracking --- Worklog Id: (was: 805205) Time Spent: 16h 50m (was: 16h 40m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 16h 50m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=804913=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-804913 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 30/Aug/22 15:24 Start Date: 30/Aug/22 15:24 Worklog Time Spent: 10m Work Description: mattrpav commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1231821231 Feels like this PR is in good shape to merge. Please provide a final review for any blocking issues and provide path forward for the in-scope features. Thank you! @cshannon @gemmellr @tabish121 @jbonofre Issue Time Tracking --- Worklog Id: (was: 804913) Time Spent: 16h 40m (was: 16.5h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 16h 40m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=804896=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-804896 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 30/Aug/22 14:30 Start Date: 30/Aug/22 14:30 Worklog Time Spent: 10m Work Description: mattrpav commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1231751311 Rebased against main post-5.17.2 release. Issue Time Tracking --- Worklog Id: (was: 804896) Time Spent: 16.5h (was: 16h 20m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 16.5h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=794907=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-794907 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Jul/22 13:50 Start Date: 25/Jul/22 13:50 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r928908219 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2MessageTypesTest.java: ## @@ -0,0 +1,582 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.Message; +import javax.jms.Session; +import javax.jms.Topic; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveMQJMS2MessageTypesTest extends ActiveMQJMS2TestBase { + +private final String clientID; +private final String destinationType; +private final String messagePayload; +private final String messageType; + +public ActiveMQJMS2MessageTypesTest(String destinationType, String messageType) { +this.clientID = destinationType + "-" + messageType; +this.destinationType = destinationType; +this.messagePayload = "Test message payload"; +this.messageType = messageType; +} + +@Parameterized.Parameters(name="destinationType={0}, messageType={1}") +public static Collection data() { +return Arrays.asList(new Object[][] { +{"queue", "bytes"}, +{"queue", "map"}, +{"queue", "object"}, +{"queue", "stream"}, +{"queue", "text"}, +{"topic", "bytes"}, +{"topic", "map"}, +{"topic", "object"}, +{"topic", "stream"}, +{"topic", "text"}, +{"temp-queue", "bytes"}, +{"temp-queue", "map"}, +{"temp-queue", "object"}, +{"temp-queue", "stream"}, +{"temp-queue", "text"}, +{"temp-topic", "bytes"}, +{"temp-topic", "map"}, +{"temp-topic", "object"}, +{"temp-topic", "stream"}, +{"temp-topic", "text"}, +}); +} + +@Test +public void testMessageDeliveryMode() { + +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin", Session.AUTO_ACKNOWLEDGE)) { +assertNotNull(jmsContext); +Destination destination = ActiveMQJMS2TestSupport.generateDestination(jmsContext, destinationType, methodNameDestinationName); +assertNotNull(destination); +JMSConsumer jmsConsumer = jmsContext.createConsumer(destination); +assertNotNull(jmsConsumer); +jmsContext.start(); + +Message message = ActiveMQJMS2TestSupport.generateMessage(jmsContext, messageType, messagePayload); + +List sentMessageIds = new LinkedList<>(); +for(int deliveryMode : Arrays.asList(DeliveryMode.NON_PERSISTENT, DeliveryMode.PERSISTENT)) { + sentMessageIds.add(ActiveMQJMS2TestSupport.sendMessage(jmsContext, destination, message, null, deliveryMode, null, null, null, null, null, null, null)); +} + +Message recvMessage = null; +List recvMessages = new LinkedList<>(); +int loopCount = 0; +int maxLoops = 50; +boolean
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=794906=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-794906 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Jul/22 13:49 Start Date: 25/Jul/22 13:49 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r928907723 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2MessageListenerTest.java: ## @@ -0,0 +1,159 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.Message; + +import org.apache.activemq.ActiveMQSession; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveMQJMS2MessageListenerTest extends ActiveMQJMS2TestBase { + +private final String destinationName; +private final String destinationType; +private final int ackMode; +private final String messagePayload; + +public ActiveMQJMS2MessageListenerTest(String destinationType, int ackMode) { +this.destinationName = "AMQ.JMS2.ACKMODE." + Integer.toString(ackMode) + destinationType.toUpperCase(); +this.destinationType = destinationType; +this.ackMode = ackMode; +this.messagePayload = "Test message destType: " + destinationType + " ackMode: " + Integer.toString(ackMode); +} + +@Parameterized.Parameters(name="destinationType={0}, ackMode={1}") +public static Collection data() { +return Arrays.asList(new Object[][] { +{"queue", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"queue", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"queue", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"queue", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"queue", ActiveMQSession.SESSION_TRANSACTED }, +{"topic", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"topic", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"topic", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"topic", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"topic", ActiveMQSession.SESSION_TRANSACTED }, +{"temp-queue", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.SESSION_TRANSACTED }, +{"temp-topic", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.SESSION_TRANSACTED } +}); +} + +@Test +public void testMessageListener() { + +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin", ackMode)) { +assertNotNull(jmsContext); +Destination destination = ActiveMQJMS2TestSupport.generateDestination(jmsContext, destinationType, destinationName); +assertNotNull(destination); +JMSConsumer jmsConsumer = jmsContext.createConsumer(destination); +ActiveMQJMS2TestMessageListener messageListener = new ActiveMQJMS2TestMessageListener(ackMode); +jmsConsumer.setMessageListener(messageListener); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=793249=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-793249 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 20/Jul/22 13:37 Start Date: 20/Jul/22 13:37 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r925618032 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2AckModesTest.java: ## @@ -0,0 +1,161 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.Message; + +import org.apache.activemq.ActiveMQSession; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveMQJMS2AckModesTest extends ActiveMQJMS2TestBase { + +private final String destinationName; +private final String destinationType; +private final int ackMode; +private final String messagePayload; + +public ActiveMQJMS2AckModesTest(String destinationType, int ackMode) { +this.destinationName = "AMQ.JMS2.ACKMODE." + Integer.toString(ackMode) + destinationType.toUpperCase(); +this.destinationType = destinationType; +this.ackMode = ackMode; +this.messagePayload = "Test message destType: " + destinationType + " ackMode: " + Integer.toString(ackMode); +} + +@Parameterized.Parameters(name="destinationType={0}, ackMode={1}") +public static Collection data() { +return Arrays.asList(new Object[][] { +{"queue", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"queue", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"queue", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"queue", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"queue", ActiveMQSession.SESSION_TRANSACTED }, +{"topic", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"topic", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"topic", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"topic", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"topic", ActiveMQSession.SESSION_TRANSACTED }, +{"temp-queue", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.SESSION_TRANSACTED }, +{"temp-topic", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.SESSION_TRANSACTED } +}); +} + +@Test +public void testAcknowledgementMode() { + +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin", ackMode)) { +assertNotNull(jmsContext); +Destination destination = ActiveMQJMS2TestSupport.generateDestination(jmsContext, destinationType, destinationName); +assertNotNull(destination); +JMSConsumer jmsConsumer = jmsContext.createConsumer(destination); +assertNotNull(jmsConsumer); +jmsContext.start(); + +Message message = ActiveMQJMS2TestSupport.generateMessage(jmsContext, "text", messagePayload); + +List sentMessageIds
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=793243=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-793243 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 20/Jul/22 13:33 Start Date: 20/Jul/22 13:33 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r925613518 ## activemq-client/src/main/java/org/apache/activemq/ActiveMQConsumer.java: ## @@ -0,0 +1,106 @@ +/** + * 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; + +import javax.jms.JMSConsumer; +import javax.jms.JMSException; +import javax.jms.JMSRuntimeException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; + +import org.apache.activemq.util.JMSExceptionSupport; + +public class ActiveMQConsumer implements JMSConsumer { + +private final ActiveMQContext activemqContext; +private final MessageConsumer activemqMessageConsumer; + +ActiveMQConsumer(ActiveMQContext activemqContext, MessageConsumer activemqMessageConsumer) { +this.activemqContext = activemqContext; +this.activemqMessageConsumer = activemqMessageConsumer; +} + +@Override +public String getMessageSelector() { +throw new UnsupportedOperationException("getMessageSelector() is not supported"); +} + +@Override +public MessageListener getMessageListener() throws JMSRuntimeException { +throw new UnsupportedOperationException("getMessageListener() is not supported"); +} + +@Override +public void setMessageListener(MessageListener listener) throws JMSRuntimeException { +throw new UnsupportedOperationException("setMessageListener(MessageListener) is not supported"); Review Comment: MessageListener support was added in this PR Issue Time Tracking --- Worklog Id: (was: 793243) Time Spent: 15h 50m (was: 15h 40m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 15h 50m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=791405=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-791405 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 15/Jul/22 13:03 Start Date: 15/Jul/22 13:03 Worklog Time Spent: 10m Work Description: mattrpav commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1185524432 Full unit test suite passing ref: https://ci-builds.apache.org/blue/organizations/jenkins/ActiveMQ%2FActiveMQ/detail/PR-729/33/pipeline Issue Time Tracking --- Worklog Id: (was: 791405) Time Spent: 15h 40m (was: 15.5h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 15h 40m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=786154=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-786154 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 29/Jun/22 17:45 Start Date: 29/Jun/22 17:45 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r910242835 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2ContextTest.java: ## @@ -0,0 +1,353 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.Enumeration; + +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.JMSRuntimeException; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import org.apache.activemq.ActiveMQContext; +import org.junit.Test; + +public class ActiveMQJMS2ContextTest extends ActiveMQJMS2TestBase { + +@Test +public void testConnectionFactoryCreateContext() { +try(JMSContext jmsContext = activemqConnectionFactory.createContext()) { +assertNotNull(jmsContext); +jmsContext.start(); + assertTrue(ActiveMQContext.class.isAssignableFrom(jmsContext.getClass())); +Destination destination = jmsContext.createQueue(methodNameDestinationName); +sendMessage(jmsContext, destination, "Test-" + methodNameDestinationName); +recvMessage(jmsContext, destination, "Test-" + methodNameDestinationName); +} catch (JMSException e) { +fail(e.getMessage()); +} +} + +@Test(expected = UnsupportedOperationException.class) +public void testConnectionFactoryCreateContextSession() { +activemqConnectionFactory.createContext(Session.AUTO_ACKNOWLEDGE); +} + +@Test +public void testConnectionFactoryCreateContextUserPass() { +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin")) { +assertNotNull(jmsContext); +jmsContext.start(); + assertTrue(ActiveMQContext.class.isAssignableFrom(jmsContext.getClass())); +Destination destination = jmsContext.createQueue(methodNameDestinationName); +sendMessage(jmsContext, destination, "Test-" + methodNameDestinationName); +recvMessage(jmsContext, destination, "Test-" + methodNameDestinationName); +} catch (JMSException e) { +fail(e.getMessage()); +} +} + +@Test +public void testConnectionFactoryCreateContextUserPassSession() { +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin", Session.AUTO_ACKNOWLEDGE)) { +assertNotNull(jmsContext); + assertTrue(ActiveMQContext.class.isAssignableFrom(jmsContext.getClass())); +} +} + +@Test +public void testConnectionFactoryCreateContexMultiContext() { +JMSContext secondJMSContext = null; +JMSContext thirdJMSContext = null; + +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin")) { +assertNotNull(jmsContext); +jmsContext.start(); + assertTrue(ActiveMQContext.class.isAssignableFrom(jmsContext.getClass())); + +Destination testDestination = jmsContext.createQueue(methodNameDestinationName); +sendMessage(jmsContext, testDestination, "Test-" + methodNameDestinationName); +recvMessage(jmsContext, testDestination, "Test-" + methodNameDestinationName); + +secondJMSContext = jmsContext.createContext(Session.AUTO_ACKNOWLEDGE); +} catch
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=786153=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-786153 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 29/Jun/22 17:44 Start Date: 29/Jun/22 17:44 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r910241941 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2AckModesTest.java: ## @@ -0,0 +1,161 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.Message; + +import org.apache.activemq.ActiveMQSession; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveMQJMS2AckModesTest extends ActiveMQJMS2TestBase { + +private final String destinationName; +private final String destinationType; +private final int ackMode; +private final String messagePayload; + +public ActiveMQJMS2AckModesTest(String destinationType, int ackMode) { +this.destinationName = "AMQ.JMS2.ACKMODE." + Integer.toString(ackMode) + destinationType.toUpperCase(); +this.destinationType = destinationType; +this.ackMode = ackMode; +this.messagePayload = "Test message destType: " + destinationType + " ackMode: " + Integer.toString(ackMode); +} + +@Parameterized.Parameters(name="destinationType={0}, ackMode={1}") +public static Collection data() { +return Arrays.asList(new Object[][] { +{"queue", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"queue", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"queue", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"queue", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"queue", ActiveMQSession.SESSION_TRANSACTED }, +{"topic", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"topic", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"topic", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"topic", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"topic", ActiveMQSession.SESSION_TRANSACTED }, +{"temp-queue", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.SESSION_TRANSACTED }, +{"temp-topic", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.SESSION_TRANSACTED } +}); +} + +@Test +public void testAcknowledgementMode() { + +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin", ackMode)) { +assertNotNull(jmsContext); +Destination destination = ActiveMQJMS2TestSupport.generateDestination(jmsContext, destinationType, destinationName); +assertNotNull(destination); +JMSConsumer jmsConsumer = jmsContext.createConsumer(destination); +assertNotNull(jmsConsumer); +jmsContext.start(); + +Message message = ActiveMQJMS2TestSupport.generateMessage(jmsContext, "text", messagePayload); + +List sentMessageIds
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=786152=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-786152 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 29/Jun/22 17:42 Start Date: 29/Jun/22 17:42 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r910240234 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2MessageTypesTest.java: ## @@ -0,0 +1,582 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.Message; +import javax.jms.Session; +import javax.jms.Topic; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveMQJMS2MessageTypesTest extends ActiveMQJMS2TestBase { + +private final String clientID; +private final String destinationType; +private final String messagePayload; +private final String messageType; + +public ActiveMQJMS2MessageTypesTest(String destinationType, String messageType) { +this.clientID = destinationType + "-" + messageType; +this.destinationType = destinationType; +this.messagePayload = "Test message payload"; +this.messageType = messageType; +} + +@Parameterized.Parameters(name="destinationType={0}, messageType={1}") +public static Collection data() { +return Arrays.asList(new Object[][] { +{"queue", "bytes"}, +{"queue", "map"}, +{"queue", "object"}, +{"queue", "stream"}, +{"queue", "text"}, +{"topic", "bytes"}, +{"topic", "map"}, +{"topic", "object"}, +{"topic", "stream"}, +{"topic", "text"}, +{"temp-queue", "bytes"}, +{"temp-queue", "map"}, +{"temp-queue", "object"}, +{"temp-queue", "stream"}, +{"temp-queue", "text"}, +{"temp-topic", "bytes"}, +{"temp-topic", "map"}, +{"temp-topic", "object"}, +{"temp-topic", "stream"}, +{"temp-topic", "text"}, +}); +} + +@Test +public void testMessageDeliveryMode() { + +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin", Session.AUTO_ACKNOWLEDGE)) { +assertNotNull(jmsContext); +Destination destination = ActiveMQJMS2TestSupport.generateDestination(jmsContext, destinationType, methodNameDestinationName); +assertNotNull(destination); +JMSConsumer jmsConsumer = jmsContext.createConsumer(destination); +assertNotNull(jmsConsumer); +jmsContext.start(); + +Message message = ActiveMQJMS2TestSupport.generateMessage(jmsContext, messageType, messagePayload); + +List sentMessageIds = new LinkedList<>(); +for(int deliveryMode : Arrays.asList(DeliveryMode.NON_PERSISTENT, DeliveryMode.PERSISTENT)) { + sentMessageIds.add(ActiveMQJMS2TestSupport.sendMessage(jmsContext, destination, message, null, deliveryMode, null, null, null, null, null, null, null)); +} + +Message recvMessage = null; +List recvMessages = new LinkedList<>(); +int loopCount = 0; +int maxLoops = 50; +boolean
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=786151=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-786151 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 29/Jun/22 17:38 Start Date: 29/Jun/22 17:38 Worklog Time Spent: 10m Work Description: mattrpav commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1170284412 Total test time down < 13s ``` [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2AckModesTest [INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.333 s - in org.apache.activemq.jms2.ActiveMQJMS2AckModesTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2ContextTest [INFO] Tests run: 25, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.297 s - in org.apache.activemq.jms2.ActiveMQJMS2ContextTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2MessageListenerTest [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.107 s - in org.apache.activemq.jms2.ActiveMQJMS2MessageListenerTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2MessageTypesTest [INFO] Tests run: 220, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.882 s - in org.apache.activemq.jms2.ActiveMQJMS2MessageTypesTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2ProducerTest [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.057 s - in org.apache.activemq.jms2.ActiveMQJMS2ProducerTest ``` Issue Time Tracking --- Worklog Id: (was: 786151) Time Spent: 15h (was: 14h 50m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 15h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
Title: Message Title ASF GitHub Bot added a worklog on AMQ-8322 mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r910181117 ## activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java: ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; if (!producer.getDisableMessageTimestamp()) { long timeStamp = System.currentTimeMillis(); + long timeStamp = System.currentTimeMillis(); + if (timeToLive > 0) { + expiration = timeToLive + timeStamp; + } + + // TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime Review Comment: This is complete Worklog entry: 10m logged by ASF GitHub Bot Change By: ASF GitHub Bot Time Spent: 14h 40m 50m Add Comment This message was sent by Atlassian Jira (v8.20.10#820010-sha1:ace47f9)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
Title: Message Title ASF GitHub Bot added a worklog on AMQ-8322 mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r910180019 ## activemq-client/src/main/java/org/apache/activemq/ActiveMQContext.java: ## @@ -0,0 +1,539 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; + +import javax.jms.BytesMessage; +import javax.jms.ConnectionMetaData; +import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.JMSRuntimeException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.jms.StreamMessage; +import javax.jms.TemporaryQueue; +import javax.jms.TemporaryTopic; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import org.apache.activemq.util.JMSExceptionSupport; + +/** + * In terms of the JMS 1.1 API a JMSContext should be thought of as + * representing both a Connection and a Session. Although the simplified + * API removes the need for applications to use those objects, the concepts + * of connection and session remain important. A connection represents a + * physical link to the JMS server and a session represents a + * single-threaded context for sending and receiving messages. + * + * + * @see javax.jms.JMSContext + */ + +public class ActiveMQContext implements JMSContext { + + private static final boolean DEFAULT_AUTO_START = true; + + private final ActiveMQConnection activemqConnection; + private final AtomicLong connectionCounter; + private ActiveMQSession activemqSession = null; + + // Configuration + private boolean autoStart = DEFAULT_AUTO_START; + private final int sessionMode; + + // State + private boolean closeInvoked = false; + private final AtomicBoolean startInvoked = new AtomicBoolean(false); + private ActiveMQMessageProducer activemqMessageProducer = null; + + ActiveMQContext(final ActiveMQConnection activemqConnection) { + this.activemqConnection = activemqConnection; + this.sessionMode = AUTO_ACKNOWLEDGE; + this.connectionCounter = new AtomicLong(1l); + } + + ActiveMQContext(final ActiveMQConnection activemqConnection, final int sessionMode) { + this.activemqConnection = activemqConnection; + this.sessionMode = sessionMode; + this.connectionCounter = new AtomicLong(1l); + } + + private ActiveMQContext(final ActiveMQConnection activemqConnection, final int sessionMode, final AtomicLong connectionCounter) { + this.activemqConnection = activemqConnection; + this.sessionMode = sessionMode; + this.connectionCounter = connectionCounter; + } + + @Override + public JMSContext createContext(int sessionMode) { + if(connectionCounter.get() == 0l) { + throw new JMSRuntimeException("Context already closed"); + } + + connectionCounter.incrementAndGet(); + return new ActiveMQContext(activemqConnection, sessionMode, connectionCounter); + } + + @Override + public JMSProducer createProducer() { + return new ActiveMQProducer(this,
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=783086=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-783086 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 20/Jun/22 17:13 Start Date: 20/Jun/22 17:13 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r901873914 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2AckModesTest.java: ## @@ -0,0 +1,161 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.Message; + +import org.apache.activemq.ActiveMQSession; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveMQJMS2AckModesTest extends ActiveMQJMS2TestBase { + +private final String destinationName; +private final String destinationType; +private final int ackMode; +private final String messagePayload; + +public ActiveMQJMS2AckModesTest(String destinationType, int ackMode) { +this.destinationName = "AMQ.JMS2.ACKMODE." + Integer.toString(ackMode) + destinationType.toUpperCase(); +this.destinationType = destinationType; +this.ackMode = ackMode; +this.messagePayload = "Test message destType: " + destinationType + " ackMode: " + Integer.toString(ackMode); +} + +@Parameterized.Parameters(name="destinationType={0}, ackMode={1}") +public static Collection data() { +return Arrays.asList(new Object[][] { +{"queue", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"queue", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"queue", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"queue", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"queue", ActiveMQSession.SESSION_TRANSACTED }, +{"topic", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"topic", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"topic", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"topic", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"topic", ActiveMQSession.SESSION_TRANSACTED }, +{"temp-queue", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.SESSION_TRANSACTED }, +{"temp-topic", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.SESSION_TRANSACTED } +}); +} + +@Test +public void testAcknowledgementMode() { + +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin", ackMode)) { +assertNotNull(jmsContext); +Destination destination = ActiveMQJMS2TestSupport.generateDestination(jmsContext, destinationType, destinationName); +assertNotNull(destination); +JMSConsumer jmsConsumer = jmsContext.createConsumer(destination); +assertNotNull(jmsConsumer); +jmsContext.start(); + +Message message = ActiveMQJMS2TestSupport.generateMessage(jmsContext, "text", messagePayload); + +List sentMessageIds
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=767152=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767152 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 06/May/22 11:52 Start Date: 06/May/22 11:52 Worklog Time Spent: 10m Work Description: gemmellr commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1119535536 > Local MacBook Pro (total 32.535s): > Apache Jenkins CI (total 43.921s): > I'm taking it from the comments here and https://github.com/apache/activemq/pull/729#discussion_r866242620) that 32-44 seconds isnt seen as a that long of a time for this, so thats going to be the key mismatch in our views. I think thats glacial for testing the stuff actually being added here, which is almost entirely fluffy wrapping to expose existing functionality with new API. I wouldnt really want to use 30sec even supposing if it included all the actual-new-functionality / behavioural stuff that hasnt yet been implemented. Issue Time Tracking --- Worklog Id: (was: 767152) Time Spent: 14h 20m (was: 14h 10m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 14h 20m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=767150=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767150 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 06/May/22 11:46 Start Date: 06/May/22 11:46 Worklog Time Spent: 10m Work Description: gemmellr commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r866748630 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2MessageTypesTest.java: ## @@ -0,0 +1,582 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.Message; +import javax.jms.Session; +import javax.jms.Topic; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveMQJMS2MessageTypesTest extends ActiveMQJMS2TestBase { + +private final String clientID; +private final String destinationType; +private final String messagePayload; +private final String messageType; + +public ActiveMQJMS2MessageTypesTest(String destinationType, String messageType) { +this.clientID = destinationType + "-" + messageType; +this.destinationType = destinationType; +this.messagePayload = "Test message payload"; +this.messageType = messageType; +} + +@Parameterized.Parameters(name="destinationType={0}, messageType={1}") +public static Collection data() { +return Arrays.asList(new Object[][] { +{"queue", "bytes"}, +{"queue", "map"}, +{"queue", "object"}, +{"queue", "stream"}, +{"queue", "text"}, +{"topic", "bytes"}, +{"topic", "map"}, +{"topic", "object"}, +{"topic", "stream"}, +{"topic", "text"}, +{"temp-queue", "bytes"}, +{"temp-queue", "map"}, +{"temp-queue", "object"}, +{"temp-queue", "stream"}, +{"temp-queue", "text"}, +{"temp-topic", "bytes"}, +{"temp-topic", "map"}, +{"temp-topic", "object"}, +{"temp-topic", "stream"}, +{"temp-topic", "text"}, Review Comment: Look at what is being tested, it has basically nothing to do with different message types, certainly not different destination types. Its mostly a waste of time (3-7sec on examples given). Even if it did have something to do with those, coverage would be better achieved far faster with specific unit tests. Add a system test or two (not 20) if needed to check the already-tested units aren't somehow wired together backwards or not at all. "as long as isnt too slow" somewhat depends on your view. Sure, 3-7 seconds isnt much in itself, but it is when considering all thats actually being verified here. 3-7sec seems orders of magnitude too slow to me for whats being tested. A few seconds here, a few seconds there, is exactly how to end up with the test suite 5.x currently has. The problem cant ever get any better if keeping doing the same things and continually making it worse. Issue Time Tracking --- Worklog Id: (was: 767150) Time Spent: 14h 10m (was: 14h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL:
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=767144=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767144 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 06/May/22 11:16 Start Date: 06/May/22 11:16 Worklog Time Spent: 10m Work Description: gemmellr commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1119508345 > > @gemmellr thank you for your prompt review. Please characterize in more detail (or point to an example) of a _unit_ test as you described. > A unit test tests a particular unit, not the entire thing. The API changes that affect the Message instances for example, almost none of them actually need a message to be sent or received, they are largely orthoganl. Even the ones that you might want to system test 'for completeness', the underlying behaviour can still be unit tested more closely without a broker. The new producer API as another example, a significant chunk of that can be tested without ever creating a connection. There are many different approaches, but a basic thing as I just covered would be I wouldnt expect the whole client or a broker to be needed at all for many of the checks for the stuff being added, which is largely just a new API for using existing functionality. The new bits can be tested in isolation. A lot of the stuff being tested never needs to hit the wire and so never needs a broker or the time wasted on starting it and connecting to it etc, or waiting on messages to be consumed to check things easily verified before they were ever actually sent etc. > I'm happy to re-work and improve test execution time and structure. Others had requested test coverage for message types and ack modes. There are other ways to cover things. E.g unit tests. Running the same system test over and over and varying things that ultimately have almost no relation to the thing being tested, is a complete waste of time. Issue Time Tracking --- Worklog Id: (was: 767144) Time Spent: 14h (was: 13h 50m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 14h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766876=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766876 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 05/May/22 19:26 Start Date: 05/May/22 19:26 Worklog Time Spent: 10m Work Description: cshannon commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r866243454 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2MessageTypesTest.java: ## @@ -0,0 +1,582 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.Message; +import javax.jms.Session; +import javax.jms.Topic; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveMQJMS2MessageTypesTest extends ActiveMQJMS2TestBase { + +private final String clientID; +private final String destinationType; +private final String messagePayload; +private final String messageType; + +public ActiveMQJMS2MessageTypesTest(String destinationType, String messageType) { +this.clientID = destinationType + "-" + messageType; +this.destinationType = destinationType; +this.messagePayload = "Test message payload"; +this.messageType = messageType; +} + +@Parameterized.Parameters(name="destinationType={0}, messageType={1}") +public static Collection data() { +return Arrays.asList(new Object[][] { +{"queue", "bytes"}, +{"queue", "map"}, +{"queue", "object"}, +{"queue", "stream"}, +{"queue", "text"}, +{"topic", "bytes"}, +{"topic", "map"}, +{"topic", "object"}, +{"topic", "stream"}, +{"topic", "text"}, +{"temp-queue", "bytes"}, +{"temp-queue", "map"}, +{"temp-queue", "object"}, +{"temp-queue", "stream"}, +{"temp-queue", "text"}, +{"temp-topic", "bytes"}, +{"temp-topic", "map"}, +{"temp-topic", "object"}, +{"temp-topic", "stream"}, +{"temp-topic", "text"}, +}); +} + +@Test +public void testMessageDeliveryMode() { + +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin", Session.AUTO_ACKNOWLEDGE)) { +assertNotNull(jmsContext); +Destination destination = ActiveMQJMS2TestSupport.generateDestination(jmsContext, destinationType, methodNameDestinationName); +assertNotNull(destination); +JMSConsumer jmsConsumer = jmsContext.createConsumer(destination); +assertNotNull(jmsConsumer); +jmsContext.start(); + +Message message = ActiveMQJMS2TestSupport.generateMessage(jmsContext, messageType, messagePayload); + +List sentMessageIds = new LinkedList<>(); +for(int deliveryMode : Arrays.asList(DeliveryMode.NON_PERSISTENT, DeliveryMode.PERSISTENT)) { + sentMessageIds.add(ActiveMQJMS2TestSupport.sendMessage(jmsContext, destination, message, null, deliveryMode, null, null, null, null, null, null, null)); +} + +Message recvMessage = null; +List recvMessages = new LinkedList<>(); +int loopCount = 0; +int maxLoops = 50; +boolean
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766875=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766875 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 05/May/22 19:24 Start Date: 05/May/22 19:24 Worklog Time Spent: 10m Work Description: cshannon commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r866242620 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2MessageTypesTest.java: ## @@ -0,0 +1,582 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.Message; +import javax.jms.Session; +import javax.jms.Topic; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveMQJMS2MessageTypesTest extends ActiveMQJMS2TestBase { + +private final String clientID; +private final String destinationType; +private final String messagePayload; +private final String messageType; + +public ActiveMQJMS2MessageTypesTest(String destinationType, String messageType) { +this.clientID = destinationType + "-" + messageType; +this.destinationType = destinationType; +this.messagePayload = "Test message payload"; +this.messageType = messageType; +} + +@Parameterized.Parameters(name="destinationType={0}, messageType={1}") +public static Collection data() { +return Arrays.asList(new Object[][] { +{"queue", "bytes"}, +{"queue", "map"}, +{"queue", "object"}, +{"queue", "stream"}, +{"queue", "text"}, +{"topic", "bytes"}, +{"topic", "map"}, +{"topic", "object"}, +{"topic", "stream"}, +{"topic", "text"}, +{"temp-queue", "bytes"}, +{"temp-queue", "map"}, +{"temp-queue", "object"}, +{"temp-queue", "stream"}, +{"temp-queue", "text"}, +{"temp-topic", "bytes"}, +{"temp-topic", "map"}, +{"temp-topic", "object"}, +{"temp-topic", "stream"}, +{"temp-topic", "text"}, Review Comment: I don't really see it as that big of a deal to test all the permutations as long as it isn't too slow. Based on the output it seems pretty quick so I'd rather check everything and than miss something. The idea of mocking and having unit tests vs system tests is a good point though. Issue Time Tracking --- Worklog Id: (was: 766875) Time Spent: 13h 40m (was: 13.5h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 13h 40m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766858=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766858 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 05/May/22 18:56 Start Date: 05/May/22 18:56 Worklog Time Spent: 10m Work Description: cshannon commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r866220901 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2MessageTypesTest.java: ## @@ -0,0 +1,582 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.Message; +import javax.jms.Session; +import javax.jms.Topic; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveMQJMS2MessageTypesTest extends ActiveMQJMS2TestBase { + +private final String clientID; +private final String destinationType; +private final String messagePayload; +private final String messageType; + +public ActiveMQJMS2MessageTypesTest(String destinationType, String messageType) { +this.clientID = destinationType + "-" + messageType; +this.destinationType = destinationType; +this.messagePayload = "Test message payload"; +this.messageType = messageType; +} + +@Parameterized.Parameters(name="destinationType={0}, messageType={1}") +public static Collection data() { +return Arrays.asList(new Object[][] { +{"queue", "bytes"}, +{"queue", "map"}, +{"queue", "object"}, +{"queue", "stream"}, +{"queue", "text"}, +{"topic", "bytes"}, +{"topic", "map"}, +{"topic", "object"}, +{"topic", "stream"}, +{"topic", "text"}, +{"temp-queue", "bytes"}, +{"temp-queue", "map"}, +{"temp-queue", "object"}, +{"temp-queue", "stream"}, +{"temp-queue", "text"}, +{"temp-topic", "bytes"}, +{"temp-topic", "map"}, +{"temp-topic", "object"}, +{"temp-topic", "stream"}, +{"temp-topic", "text"}, +}); +} + +@Test +public void testMessageDeliveryMode() { + +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin", Session.AUTO_ACKNOWLEDGE)) { +assertNotNull(jmsContext); +Destination destination = ActiveMQJMS2TestSupport.generateDestination(jmsContext, destinationType, methodNameDestinationName); +assertNotNull(destination); +JMSConsumer jmsConsumer = jmsContext.createConsumer(destination); +assertNotNull(jmsConsumer); +jmsContext.start(); + +Message message = ActiveMQJMS2TestSupport.generateMessage(jmsContext, messageType, messagePayload); + +List sentMessageIds = new LinkedList<>(); +for(int deliveryMode : Arrays.asList(DeliveryMode.NON_PERSISTENT, DeliveryMode.PERSISTENT)) { + sentMessageIds.add(ActiveMQJMS2TestSupport.sendMessage(jmsContext, destination, message, null, deliveryMode, null, null, null, null, null, null, null)); +} + +Message recvMessage = null; +List recvMessages = new LinkedList<>(); +int loopCount = 0; +int maxLoops = 50; +boolean
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766856=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766856 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 05/May/22 18:53 Start Date: 05/May/22 18:53 Worklog Time Spent: 10m Work Description: mattrpav commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1118937154 Unit test execution times: Local MacBook Pro: ``` [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2AckModesTest [INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.601 s - in org.apache.activemq.jms2.ActiveMQJMS2AckModesTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2ContextTest [INFO] Tests run: 25, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.318 s - in org.apache.activemq.jms2.ActiveMQJMS2ContextTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2MessageListenerTest [INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 15.343 s - in org.apache.activemq.jms2.ActiveMQJMS2MessageListenerTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2MessageTypesTest [INFO] Tests run: 220, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.216 s - in org.apache.activemq.jms2.ActiveMQJMS2MessageTypesTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2ProducerTest [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.057 s - in org.apache.activemq.jms2.ActiveMQJMS2ProducerTest ``` Apache Jenkins CI: ``` [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2AckModesTest [INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.42 s - in org.apache.activemq.jms2.ActiveMQJMS2AckModesTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2ContextTest [INFO] Tests run: 25, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.07 s - in org.apache.activemq.jms2.ActiveMQJMS2ContextTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2MessageListenerTest [INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 17.283 s - in org.apache.activemq.jms2.ActiveMQJMS2MessageListenerTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2MessageTypesTest [INFO] Tests run: 220, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.782 s - in org.apache.activemq.jms2.ActiveMQJMS2MessageTypesTest [INFO] Running org.apache.activemq.jms2.ActiveMQJMS2ProducerTest [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.366 s - in org.apache.activemq.jms2.ActiveMQJMS2ProducerTest ``` Issue Time Tracking --- Worklog Id: (was: 766856) Time Spent: 13h 20m (was: 13h 10m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 13h 20m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766789=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766789 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 05/May/22 17:07 Start Date: 05/May/22 17:07 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r866134814 ## activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java: ## @@ -0,0 +1,545 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final ActiveMQMessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Integer deliveryMode = null; +private Boolean disableMessageID = false; +private Boolean disableMessageTimestamp = false; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, ActiveMQMessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive(), getDisableMessageID(), getDisableMessageTimestamp(), null); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766779=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766779 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 05/May/22 16:59 Start Date: 05/May/22 16:59 Worklog Time Spent: 10m Work Description: mattrpav commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1118836849 > I'll admit I gave up before the end as many of the comments seem to apply to a lot of the tests and I got bored seeing/saying the same things, but I cant say I saw an actual _unit_ test despite the various comments about them. Just lots of system/integration tests running up full brokers and clients, often to check things that dont even hit the wire at all. Given a lot of this stuff just wraps existing impl it is easy to unit test those wrapping bits in isolation, system testing all of it in that way seems largely just a waste, but even more so when also repeating tests for every type of destination or message type or ack mode etcand doing so without _any_ unit tests that could achivee the same more quickly and give better errors on failure etc. @gemmellr thank you for your prompt review. Please characterize in more detail (or point to an example) of a _unit_ test as you described. I'm happy to re-work and improve test execution time and structure. Others had requested test coverage for message types and ack modes. Issue Time Tracking --- Worklog Id: (was: 766779) Time Spent: 13h (was: 12h 50m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 13h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766777=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766777 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 05/May/22 16:51 Start Date: 05/May/22 16:51 Worklog Time Spent: 10m Work Description: gemmellr commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1118822433 I'll admit I gave up before the end as many of the comments seem to apply to a lot of the tests and I got bored seeing/saying the same things, but I cant say I saw an actual _unit_ test despite the various comments about them. Just lots of system/integration tests running up full brokers and clients, often to check things that dont even hit the wire at all. Given a lot of this stuff just wraps existing impl it is easy to unit test those wrapping bits in isolation, system testing all of it in that way seems largely just a waste, but even more so when also repeating tests for every type of destination or message type or ack mode etcand doing so without _any_ unit tests that could achivee the same more quickly and give better errors on failure etc. Issue Time Tracking --- Worklog Id: (was: 766777) Time Spent: 12h 50m (was: 12h 40m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 12h 50m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766773=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766773 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 05/May/22 16:43 Start Date: 05/May/22 16:43 Worklog Time Spent: 10m Work Description: gemmellr commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r865989689 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2AckModesTest.java: ## @@ -0,0 +1,161 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.Message; + +import org.apache.activemq.ActiveMQSession; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveMQJMS2AckModesTest extends ActiveMQJMS2TestBase { + +private final String destinationName; +private final String destinationType; +private final int ackMode; +private final String messagePayload; + +public ActiveMQJMS2AckModesTest(String destinationType, int ackMode) { +this.destinationName = "AMQ.JMS2.ACKMODE." + Integer.toString(ackMode) + destinationType.toUpperCase(); +this.destinationType = destinationType; +this.ackMode = ackMode; +this.messagePayload = "Test message destType: " + destinationType + " ackMode: " + Integer.toString(ackMode); +} + +@Parameterized.Parameters(name="destinationType={0}, ackMode={1}") +public static Collection data() { +return Arrays.asList(new Object[][] { +{"queue", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"queue", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"queue", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"queue", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"queue", ActiveMQSession.SESSION_TRANSACTED }, +{"topic", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"topic", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"topic", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"topic", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"topic", ActiveMQSession.SESSION_TRANSACTED }, +{"temp-queue", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"temp-queue", ActiveMQSession.SESSION_TRANSACTED }, +{"temp-topic", ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.AUTO_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.CLIENT_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.DUPS_OK_ACKNOWLEDGE }, +{"temp-topic", ActiveMQSession.SESSION_TRANSACTED } +}); +} + +@Test +public void testAcknowledgementMode() { + +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin", ackMode)) { +assertNotNull(jmsContext); +Destination destination = ActiveMQJMS2TestSupport.generateDestination(jmsContext, destinationType, destinationName); +assertNotNull(destination); +JMSConsumer jmsConsumer = jmsContext.createConsumer(destination); +assertNotNull(jmsConsumer); +jmsContext.start(); + +Message message = ActiveMQJMS2TestSupport.generateMessage(jmsContext, "text", messagePayload); + +List sentMessageIds
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766649=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766649 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 05/May/22 13:46 Start Date: 05/May/22 13:46 Worklog Time Spent: 10m Work Description: mattrpav commented on PR #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1118574916 @gemmellr @tabish121 @cshannon @jbonofre I have gone through all the requests in previous review rounds and believe I have addressed all open items. Please review the latest. Thank you Issue Time Tracking --- Worklog Id: (was: 766649) Time Spent: 12.5h (was: 12h 20m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 12.5h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766082=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766082 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 04/May/22 15:12 Start Date: 04/May/22 15:12 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r864960783 ## activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java: ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); + } else if
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766081=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766081 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 04/May/22 15:11 Start Date: 04/May/22 15:11 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r864960056 ## activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java: ## @@ -1956,12 +1976,15 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); Review Comment: This is completed Issue Time Tracking --- Worklog Id: (was: 766081) Time Spent: 12h 10m (was: 12h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 12h 10m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=766079=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-766079 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 04/May/22 15:10 Start Date: 04/May/22 15:10 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r864958409 ## activemq-unit-tests/src/test/java/org/apache/activemq/jms2/ActiveMQJMS2ContextTest.java: ## @@ -0,0 +1,302 @@ +/** + * 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.jms2; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.Enumeration; + +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.JMSRuntimeException; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.jms.TextMessage; + +import org.apache.activemq.ActiveMQContext; +import org.junit.Test; + +public class ActiveMQJMS2ContextTest extends ActiveMQJMS2TestBase { + +@Test +public void testConnectionFactoryCreateContext() { +try(JMSContext jmsContext = activemqConnectionFactory.createContext()) { +assertNotNull(jmsContext); +jmsContext.start(); + assertTrue(ActiveMQContext.class.isAssignableFrom(jmsContext.getClass())); +sendMessage(jmsContext, methodNameDestinationName); +recvMessage(jmsContext, methodNameDestinationName, "Test-" + methodNameDestinationName); +} catch (JMSException e) { +fail(e.getMessage()); +} +} + +@Test(expected = UnsupportedOperationException.class) +public void testConnectionFactoryCreateContextSession() { +activemqConnectionFactory.createContext(Session.AUTO_ACKNOWLEDGE); +} + +@Test +public void testConnectionFactoryCreateContextUserPass() { +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin")) { +assertNotNull(jmsContext); +jmsContext.start(); + assertTrue(ActiveMQContext.class.isAssignableFrom(jmsContext.getClass())); +sendMessage(jmsContext, methodNameDestinationName); +recvMessage(jmsContext, methodNameDestinationName, "Test-" + methodNameDestinationName); +} catch (JMSException e) { +fail(e.getMessage()); +} +} + +@Test +public void testConnectionFactoryCreateContextUserPassSession() { +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin", Session.AUTO_ACKNOWLEDGE)) { +assertNotNull(jmsContext); + assertTrue(ActiveMQContext.class.isAssignableFrom(jmsContext.getClass())); +} +} + +@Test +public void testConnectionFactoryCreateContexMultiContext() { +JMSContext secondJMSContext = null; +JMSContext thirdJMSContext = null; + +try(JMSContext jmsContext = activemqConnectionFactory.createContext("admin", "admin")) { +assertNotNull(jmsContext); +jmsContext.start(); + assertTrue(ActiveMQContext.class.isAssignableFrom(jmsContext.getClass())); +sendMessage(jmsContext, methodNameDestinationName); +recvMessage(jmsContext, methodNameDestinationName, "Test-" + methodNameDestinationName); + +secondJMSContext = jmsContext.createContext(Session.AUTO_ACKNOWLEDGE); +} catch (JMSException e) { +fail(e.getMessage()); +} + +// First context closed +String secondTestDestinationName = methodNameDestinationName + ".SECOND"; +try { +sendMessage(secondJMSContext, secondTestDestinationName); +recvMessage(secondJMSContext, secondTestDestinationName, "Test-" +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=763557=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-763557 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 28/Apr/22 14:49 Start Date: 28/Apr/22 14:49 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r860985522 ## activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java: ## @@ -0,0 +1,546 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final ActiveMQMessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Integer deliveryMode = null; +private Boolean disableMessageID = false; +private Boolean disableMessageTimestamp = false; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, ActiveMQMessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive(), getDisableMessageID(), getDisableMessageTimestamp(), null); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=763558=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-763558 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 28/Apr/22 14:49 Start Date: 28/Apr/22 14:49 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r860985881 ## activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java: ## @@ -0,0 +1,546 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final ActiveMQMessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Integer deliveryMode = null; +private Boolean disableMessageID = false; +private Boolean disableMessageTimestamp = false; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, ActiveMQMessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive(), getDisableMessageID(), getDisableMessageTimestamp(), null); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=763133=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-763133 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 27/Apr/22 19:48 Start Date: 27/Apr/22 19:48 Worklog Time Spent: 10m Work Description: mattrpav commented on code in PR #729: URL: https://github.com/apache/activemq/pull/729#discussion_r860186493 ## activemq-client/src/main/java/org/apache/activemq/ActiveMQConsumer.java: ## @@ -0,0 +1,106 @@ +/** + * 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; + +import javax.jms.JMSConsumer; +import javax.jms.JMSException; +import javax.jms.JMSRuntimeException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; + +import org.apache.activemq.util.JMSExceptionSupport; + +public class ActiveMQConsumer implements JMSConsumer { + +private final ActiveMQContext activemqContext; +private final MessageConsumer activemqMessageConsumer; + +ActiveMQConsumer(ActiveMQContext activemqContext, MessageConsumer activemqMessageConsumer) { +this.activemqContext = activemqContext; +this.activemqMessageConsumer = activemqMessageConsumer; +} + +@Override +public String getMessageSelector() { +throw new UnsupportedOperationException("getMessageSelector() is not supported"); +} + +@Override +public MessageListener getMessageListener() throws JMSRuntimeException { +throw new UnsupportedOperationException("getMessageListener() is not supported"); +} + +@Override +public void setMessageListener(MessageListener listener) throws JMSRuntimeException { +throw new UnsupportedOperationException("setMessageListener(MessageListener) is not supported"); Review Comment: This is done Issue Time Tracking --- Worklog Id: (was: 763133) Time Spent: 11.5h (was: 11h 20m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 11.5h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=733163=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-733163 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Feb/22 16:44 Start Date: 25/Feb/22 16:44 Worklog Time Spent: 10m Work Description: tabish121 commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r814924223 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,546 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final ActiveMQMessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Integer deliveryMode = null; +private Boolean disableMessageID = false; +private Boolean disableMessageTimestamp = false; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, ActiveMQMessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive(), getDisableMessageID(), getDisableMessageTimestamp(), null); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=733137=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-733137 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Feb/22 16:12 Start Date: 25/Feb/22 16:12 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r814898644 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,546 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final ActiveMQMessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Integer deliveryMode = null; +private Boolean disableMessageID = false; +private Boolean disableMessageTimestamp = false; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, ActiveMQMessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive(), getDisableMessageID(), getDisableMessageTimestamp(), null); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=733132=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-733132 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Feb/22 16:07 Start Date: 25/Feb/22 16:07 Worklog Time Spent: 10m Work Description: tabish121 commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r814894558 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,546 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final ActiveMQMessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Integer deliveryMode = null; +private Boolean disableMessageID = false; +private Boolean disableMessageTimestamp = false; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, ActiveMQMessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive(), getDisableMessageID(), getDisableMessageTimestamp(), null); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=733096=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-733096 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Feb/22 15:11 Start Date: 25/Feb/22 15:11 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r814848682 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,546 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.DeliveryMode; +import javax.jms.Destination; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final ActiveMQMessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Integer deliveryMode = null; +private Boolean disableMessageID = false; +private Boolean disableMessageTimestamp = false; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, ActiveMQMessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive(), getDisableMessageID(), getDisableMessageTimestamp(), null); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=733092=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-733092 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Feb/22 15:08 Start Date: 25/Feb/22 15:08 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r814845539 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQConsumer.java ## @@ -0,0 +1,118 @@ +/** + * 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; + +import javax.jms.JMSConsumer; +import javax.jms.JMSException; +import javax.jms.JMSRuntimeException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; + +import org.apache.activemq.util.JMSExceptionSupport; + +public class ActiveMQConsumer implements JMSConsumer { + +private final ActiveMQContext activemqContext; +private final MessageConsumer activemqMessageConsumer; + +ActiveMQConsumer(ActiveMQContext activemqContext, MessageConsumer activemqMessageConsumer) { +this.activemqContext = activemqContext; +this.activemqMessageConsumer = activemqMessageConsumer; +} + +@Override +public String getMessageSelector() { +try { +return activemqMessageConsumer.getMessageSelector(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public MessageListener getMessageListener() throws JMSRuntimeException { +try { +return activemqMessageConsumer.getMessageListener(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public void setMessageListener(MessageListener listener) throws JMSRuntimeException { +try { +activemqMessageConsumer.setMessageListener(listener); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public Message receive() { +try { +return activemqMessageConsumer.receive(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public Message receive(long timeout) { +try { +return activemqMessageConsumer.receive(timeout); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public Message receiveNoWait() { +try { +return activemqMessageConsumer.receiveNoWait(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public void close() { +try { +activemqMessageConsumer.close(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public T receiveBody(Class c) { +throw new UnsupportedOperationException("receiveBody(Class) is not supported"); Review comment: Yep. ref: [AMQ-8321](https://issues.apache.org/jira/browse/AMQ-8321) -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 733092) Time Spent: 10h 40m (was: 10.5h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ >
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=732756=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-732756 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 24/Feb/22 23:01 Start Date: 24/Feb/22 23:01 Worklog Time Spent: 10m Work Description: tabish121 commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r814326069 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQConsumer.java ## @@ -0,0 +1,118 @@ +/** + * 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; + +import javax.jms.JMSConsumer; +import javax.jms.JMSException; +import javax.jms.JMSRuntimeException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; + +import org.apache.activemq.util.JMSExceptionSupport; + +public class ActiveMQConsumer implements JMSConsumer { + +private final ActiveMQContext activemqContext; +private final MessageConsumer activemqMessageConsumer; + +ActiveMQConsumer(ActiveMQContext activemqContext, MessageConsumer activemqMessageConsumer) { +this.activemqContext = activemqContext; +this.activemqMessageConsumer = activemqMessageConsumer; +} + +@Override +public String getMessageSelector() { +try { +return activemqMessageConsumer.getMessageSelector(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public MessageListener getMessageListener() throws JMSRuntimeException { +try { +return activemqMessageConsumer.getMessageListener(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public void setMessageListener(MessageListener listener) throws JMSRuntimeException { +try { +activemqMessageConsumer.setMessageListener(listener); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public Message receive() { +try { +return activemqMessageConsumer.receive(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public Message receive(long timeout) { +try { +return activemqMessageConsumer.receive(timeout); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public Message receiveNoWait() { +try { +return activemqMessageConsumer.receiveNoWait(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public void close() { +try { +activemqMessageConsumer.close(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public T receiveBody(Class c) { +throw new UnsupportedOperationException("receiveBody(Class) is not supported"); Review comment: These receive methods are the basic meat of the simplified API so it is odd that they aren't implemented yet but I hope they would be done shortly after this phase as they should be able to leverage most of what's in the client already with a few additions in ActiveMQMessage and some consumer changes to handle the failure cases. ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,546 @@ +/** + * 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 + *
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=732755=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-732755 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 24/Feb/22 22:55 Start Date: 24/Feb/22 22:55 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r814339958 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQContext.java ## @@ -0,0 +1,539 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; + +import javax.jms.BytesMessage; +import javax.jms.ConnectionMetaData; +import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.JMSRuntimeException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.jms.StreamMessage; +import javax.jms.TemporaryQueue; +import javax.jms.TemporaryTopic; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import org.apache.activemq.util.JMSExceptionSupport; + +/** + * In terms of the JMS 1.1 API a JMSContext should be thought of as + * representing both a Connection and a Session. Although the simplified + * API removes the need for applications to use those objects, the concepts + * of connection and session remain important. A connection represents a + * physical link to the JMS server and a session represents a + * single-threaded context for sending and receiving messages. + * + * + * @see javax.jms.JMSContext + */ + +public class ActiveMQContext implements JMSContext { + +private static final boolean DEFAULT_AUTO_START = true; + +private final ActiveMQConnection activemqConnection; +private final AtomicLong connectionCounter; +private ActiveMQSession activemqSession = null; + +// Configuration +private boolean autoStart = DEFAULT_AUTO_START; +private final int sessionMode; + +// State +private boolean closeInvoked = false; +private final AtomicBoolean startInvoked = new AtomicBoolean(false); +private ActiveMQMessageProducer activemqMessageProducer = null; + +ActiveMQContext(final ActiveMQConnection activemqConnection) { +this.activemqConnection = activemqConnection; +this.sessionMode = AUTO_ACKNOWLEDGE; +this.connectionCounter = new AtomicLong(1l); +} + +ActiveMQContext(final ActiveMQConnection activemqConnection, final int sessionMode) { +this.activemqConnection = activemqConnection; +this.sessionMode = sessionMode; +this.connectionCounter = new AtomicLong(1l); +} + +private ActiveMQContext(final ActiveMQConnection activemqConnection, final int sessionMode, final AtomicLong connectionCounter) { +this.activemqConnection = activemqConnection; +this.sessionMode = sessionMode; +this.connectionCounter = connectionCounter; +} + +@Override +public JMSContext createContext(int sessionMode) { +if(connectionCounter.get() == 0l) { +throw new JMSRuntimeException("Context already closed"); +} + +connectionCounter.incrementAndGet(); +return new ActiveMQContext(activemqConnection, sessionMode, connectionCounter); +} + +@Override +public JMSProducer createProducer() { +return new ActiveMQProducer(this, getCreatedActiveMQMessageProducer()); +} + +@Override +public String getClientID() { +try { +return this.activemqConnection.getClientID(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=732742=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-732742 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 24/Feb/22 22:32 Start Date: 24/Feb/22 22:32 Worklog Time Spent: 10m Work Description: tabish121 commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r814324076 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQContext.java ## @@ -0,0 +1,539 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; + +import javax.jms.BytesMessage; +import javax.jms.ConnectionMetaData; +import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.JMSRuntimeException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.jms.StreamMessage; +import javax.jms.TemporaryQueue; +import javax.jms.TemporaryTopic; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import org.apache.activemq.util.JMSExceptionSupport; + +/** + * In terms of the JMS 1.1 API a JMSContext should be thought of as + * representing both a Connection and a Session. Although the simplified + * API removes the need for applications to use those objects, the concepts + * of connection and session remain important. A connection represents a + * physical link to the JMS server and a session represents a + * single-threaded context for sending and receiving messages. + * + * + * @see javax.jms.JMSContext + */ + +public class ActiveMQContext implements JMSContext { + +private static final boolean DEFAULT_AUTO_START = true; + +private final ActiveMQConnection activemqConnection; +private final AtomicLong connectionCounter; +private ActiveMQSession activemqSession = null; + +// Configuration +private boolean autoStart = DEFAULT_AUTO_START; +private final int sessionMode; + +// State +private boolean closeInvoked = false; +private final AtomicBoolean startInvoked = new AtomicBoolean(false); +private ActiveMQMessageProducer activemqMessageProducer = null; + +ActiveMQContext(final ActiveMQConnection activemqConnection) { +this.activemqConnection = activemqConnection; +this.sessionMode = AUTO_ACKNOWLEDGE; +this.connectionCounter = new AtomicLong(1l); +} + +ActiveMQContext(final ActiveMQConnection activemqConnection, final int sessionMode) { +this.activemqConnection = activemqConnection; +this.sessionMode = sessionMode; +this.connectionCounter = new AtomicLong(1l); +} + +private ActiveMQContext(final ActiveMQConnection activemqConnection, final int sessionMode, final AtomicLong connectionCounter) { +this.activemqConnection = activemqConnection; +this.sessionMode = sessionMode; +this.connectionCounter = connectionCounter; +} + +@Override +public JMSContext createContext(int sessionMode) { +if(connectionCounter.get() == 0l) { +throw new JMSRuntimeException("Context already closed"); +} + +connectionCounter.incrementAndGet(); +return new ActiveMQContext(activemqConnection, sessionMode, connectionCounter); +} + +@Override +public JMSProducer createProducer() { +return new ActiveMQProducer(this, getCreatedActiveMQMessageProducer()); +} + +@Override +public String getClientID() { +try { +return this.activemqConnection.getClientID(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731877=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731877 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 23/Feb/22 19:52 Start Date: 23/Feb/22 19:52 Worklog Time Spent: 10m Work Description: mattrpav edited a comment on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1049104564 That amqp test fix worked. I'm going to break it out into a separate PR for consideration into 5.17.0 -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731877) Time Spent: 10h (was: 9h 50m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 10h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731809=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731809 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 23/Feb/22 18:54 Start Date: 23/Feb/22 18:54 Worklog Time Spent: 10m Work Description: mattrpav commented on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1049104564 That amqp test fix worked. I'm going to break it out into a separate PR -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731809) Time Spent: 9h 50m (was: 9h 40m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 9h 50m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731749=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731749 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 23/Feb/22 17:45 Start Date: 23/Feb/22 17:45 Worklog Time Spent: 10m Work Description: gemmellr commented on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1049044074 AH, I somehow missed the last line of your previous message :) -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731749) Time Spent: 9h 40m (was: 9.5h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 9h 40m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731738=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731738 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 23/Feb/22 17:29 Start Date: 23/Feb/22 17:29 Worklog Time Spent: 10m Work Description: mattrpav commented on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1049029799 @gemmellr yep. in my update to the test, I explicitly set the trusted packages list to a new list and get rid of using the system property (which may have been causing the irregularity). The ActiveMQConnectionFactory.getTrustedPackges() list is wired into the connection each time, so updates there should carry over regardless of the static block in CLAOIS ``` ActiveMQConnectionFactory#configureConnection(ActiveMQConnection) connection.setTrustedPackages(getTrustedPackages()); ``` -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731738) Time Spent: 9.5h (was: 9h 20m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 9.5h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731681=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731681 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 23/Feb/22 16:27 Start Date: 23/Feb/22 16:27 Worklog Time Spent: 10m Work Description: gemmellr commented on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1048966869 The value set by the property in ClassLoadingAwareObjectInputStream is a static, so updating it doesnt do anything if already set when the codepath has been first used. So the first test to use that codepath will lock the value down. If a test sets the value itself before it is ever used, then running that test in isolation will always work. If another test is run before it in the same suite in the same JVM and exercises that codepath first with a mismatched value, the subsequent tests setter will have no effect on what actually happens, and the test will fail. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731681) Time Spent: 9h 20m (was: 9h 10m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.18.0 > > Time Spent: 9h 20m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731627=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731627 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 23/Feb/22 15:06 Start Date: 23/Feb/22 15:06 Worklog Time Spent: 10m Work Description: mattrpav edited a comment on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1048875347 > @mattrpav it seems related to security enforcement we added. But it should fail on your machine as well. I agree with you =) The connection factory is setup without setting trusted packages: AmqpTestSupport#createJMSConnection() ``` ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(openwireURI); return factory.createConnection(); ``` .. which defaults to ClassLoadingAwareObjectInputStream#static{} ``` serializablePackages = System.getProperty("org.apache.activemq.SERIALIZABLE_PACKAGES","java.lang,org.apache.activemq,org.fusesource.hawtbuf,com.thoughtworks.xstream.mapper").split(","); ``` .. but should be overidden by AmqpTestSupport#setUp ``` System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES", "java.util"); ``` Hmm.. that could be an order of operations problem. I'm going to change the test to add 'java.util' to the list when it instantiates the connection factory. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731627) Time Spent: 9h 10m (was: 9h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 9h 10m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731625=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731625 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 23/Feb/22 15:03 Start Date: 23/Feb/22 15:03 Worklog Time Spent: 10m Work Description: mattrpav edited a comment on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1048875347 > @mattrpav it seems related to security enforcement we added. But it should fail on your machine as well. I agree with you =) The connection factory is setup without setting trusted packages: AmqpTestSupport#createJMSConnection() ``` ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(openwireURI); return factory.createConnection(); ``` .. which defaults to ClassLoadingAwareObjectInputStream#static{} ``` serializablePackages = System.getProperty("org.apache.activemq.SERIALIZABLE_PACKAGES","java.lang,org.apache.activemq,org.fusesource.hawtbuf,com.thoughtworks.xstream.mapper").split(","); ``` .. but is overidden by AmqpTestSupport#setUp ``` System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES", "java.util"); ``` Hmm.. that could be an order of operations problem. I'm going to change the test to add 'java.util' to the list when it instantiates the connection factory. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731625) Time Spent: 9h (was: 8h 50m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 9h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731624=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731624 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 23/Feb/22 15:02 Start Date: 23/Feb/22 15:02 Worklog Time Spent: 10m Work Description: mattrpav commented on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1048875347 > @mattrpav it seems related to security enforcement we added. But it should fail on your machine as well. I agree with you =). The connection factory is setup without setting trusted packages: AmqpTestSupport#createJMSConnection() ``` ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(openwireURI); return factory.createConnection(); ``` .. which defaults to ClassLoadingAwareObjectInputStream#static{} ``` serializablePackages = System.getProperty("org.apache.activemq.SERIALIZABLE_PACKAGES","java.lang,org.apache.activemq,org.fusesource.hawtbuf,com.thoughtworks.xstream.mapper").split(","); ``` .. but is overidden by AmqpTestSupport#setUp ``` System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES", "java.util"); ``` -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731624) Time Spent: 8h 50m (was: 8h 40m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 8h 50m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731620=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731620 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 23/Feb/22 14:56 Start Date: 23/Feb/22 14:56 Worklog Time Spent: 10m Work Description: jbonofre commented on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1048869857 @mattrpav it seems related to security enforcement we added. But it should fail on your machine as well. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731620) Time Spent: 8h 40m (was: 8.5h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 8h 40m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731617=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731617 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 23/Feb/22 14:51 Start Date: 23/Feb/22 14:51 Worklog Time Spent: 10m Work Description: mattrpav commented on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1048864601 Grrr.. fighting with one test that passes-locally-fails-on-apache-ci. The test totally looks like it could be something that was impacted by the changes in the PR, but the exception stack doesn't align Test: activemq-amqp/JMSInteroperabilityTest.testQpidToOpenWireObjectMessage ``` javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class java.util.UUID! This class is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes. at org.apache.activemq.transport.amqp.JMSInteroperabilityTest.testQpidToOpenWireObjectMessage(JMSInteroperabilityTest.java:402) Caused by: java.lang.ClassNotFoundException: Forbidden class java.util.UUID! This class is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes. at org.apache.activemq.transport.amqp.JMSInteroperabilityTest.testQpidToOpenWireObjectMessage(JMSInteroperabilityTest.java:402) ``` -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731617) Time Spent: 8.5h (was: 8h 20m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 8.5h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731069=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731069 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 16:49 Start Date: 22/Feb/22 16:49 Worklog Time Spent: 10m Work Description: mattrpav edited a comment on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1047814435 @gemmellr yep, saw that. Def related to your points above. I’m cleaning that up first thing this morning. UPDATE: Change is in for deliveryTime http unit tests passed locally (including the foreign message test). Pending Jenkins CI job to go 'green' -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731069) Time Spent: 8h 20m (was: 8h 10m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 8h 20m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731060=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731060 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 16:21 Start Date: 22/Feb/22 16:21 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r812124287 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime +message.setJMSDeliveryTime(timeStamp); Review comment: Agreed that it is tough to find a meaningful use case on the receiver side. Maybe detecting clock skew? Yeah.. its narrow at best. I'll go with JMSTimestamp alignment for now and see how that feels once the tests are flushed out. I think it'll have the small benefit of making the documentation more straight-foward. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731060) Time Spent: 8h 10m (was: 8h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 8h 10m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731006=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731006 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 15:04 Start Date: 22/Feb/22 15:04 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r812041572 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime +message.setJMSDeliveryTime(timeStamp); Review comment: I could go other way on that one. Both are about as non-meaningful as each other, as they will be in the past from the recievers perspective. 0 is like the 'defaullt', ala expiration etc. Tbh I'm not sure I actually know of a reason to look at the value after receiving a message, except as part of an implementation test hehe. I think from your 'getFromMessageDeliveryTime(Message fromMessage)' inclusion you mean during the send though. In that case, strictly speaking I guess you dont necessarily need to get the value as you are about to _set_ the value, so the original is actually redundant. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731006) Time Spent: 8h (was: 7h 50m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 8h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731005=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731005 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 15:03 Start Date: 22/Feb/22 15:03 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r812041572 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime +message.setJMSDeliveryTime(timeStamp); Review comment: I could go other way on that one. Both are about as non-meaningful as each other, as they will be in the past from the recievers perspective. 0 is like the 'defaullt', ala expiration etc. Tbh I'm not sure I actually know of a reason to look at the value after receiving a message, except as part of an implementation test hehe. I think from your 'getFromMessageDeliveryTime(Message fromMessage)' inclusion you mean during the send though. In that case, strictly speaking I guess you dont necessarily need to get the value as you are about to _set_ the value. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731005) Time Spent: 7h 50m (was: 7h 40m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 7h 50m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=731003=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731003 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 15:02 Start Date: 22/Feb/22 15:02 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r812040334 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime +message.setJMSDeliveryTime(timeStamp); Review comment: Got it. I'm working on both the set and the get side of it. Can I get your thoughts on the above? JMSTimestamp vs zero for non-JMS 2.0 messages. Thanks -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 731003) Time Spent: 7h 40m (was: 7.5h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 7h 40m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730987=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730987 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 14:47 Start Date: 22/Feb/22 14:47 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r812024149 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime +message.setJMSDeliveryTime(timeStamp); Review comment: I should probably also note that this call will fail even for a native 5.x message, if the 1.1 API is the primary interface on the classpath, as the method 'wont exist' even though 5.x implements it. To avoid that you need to use an ActiveMQMessage impl ref to call the method rather than the Message interface. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 730987) Time Spent: 7.5h (was: 7h 20m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 7.5h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730981=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730981 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 14:42 Start Date: 22/Feb/22 14:42 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r812019255 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime +message.setJMSDeliveryTime(timeStamp); Review comment: @gemmellr what are your thoughts on returning JMSTimestamp vs zero for the v1 use case? getFromMessageDeliveryTime(Message fromMessage) 1. Check for the existence of the getJMSDeliveryTime method 2. If so (ie.. v2 message) return value 3. If not, return the JMSTimestamp value Earlier we had discussed using JMSTimestamp as the fallback since it is a required field. This would align the behavior across ActiveMQ usage. It looks like qpid is returning 0 in this case. Is there a specific reason to return 0 here? Thanks -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 730981) Time Spent: 7h 20m (was: 7h 10m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 7h 20m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730965=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730965 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 14:33 Start Date: 22/Feb/22 14:33 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r812010040 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime +message.setJMSDeliveryTime(timeStamp); Review comment: For the record, I try to avoid barfing exceptions whenever possible ;-) It was unexpected to me that this level of reflection would be the solution. I'm working on it now. That foreign message test over in http is helpful and will provide good feedback -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 730965) Time Spent: 7h 10m (was: 7h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 7h 10m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730909=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730909 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 13:48 Start Date: 22/Feb/22 13:48 Worklog Time Spent: 10m Work Description: mattrpav commented on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1047814435 @gemmellr yep, saw that. Def related to your points above. I’m cleaning that up first thing this morning. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 730909) Time Spent: 7h (was: 6h 50m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 7h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730898=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730898 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 13:30 Start Date: 22/Feb/22 13:30 Worklog Time Spent: 10m Work Description: gemmellr commented on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1047798838 Note the PR build is still failing, with: [INFO] Running org.apache.activemq.transport.http.HttpJMSMessageTest [ERROR] Tests run: 32, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 16.633 s <<< FAILURE! - in org.apache.activemq.transport.http.HttpJMSMessageTest [ERROR] testForeignMessage {connectURL=vm://localhost?marshal=false, deliveryMode=1, destinationType=1}(org.apache.activemq.transport.http.HttpJMSMessageTest) Time elapsed: 0.441 s <<< ERROR! java.lang.AbstractMethodError: Receiver class org.apache.activemq.JMSMessageTest$ForeignMessage does not define or inherit an implementation of the resolved method abstract setJMSDeliveryTime(J)V of interface javax.jms.Message. etc etc (Dont know about the non-PR build) -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 730898) Time Spent: 6h 50m (was: 6h 40m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 6h 50m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730893=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730893 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 13:27 Start Date: 22/Feb/22 13:27 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811943438 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime +message.setJMSDeliveryTime(timeStamp); Review comment: Not much. You already have to check that it is a foreign message, and are already going to the expense of converting it, this cost need only apply in those cases. Relative to e.g the round trip to the broker for any reliable messaging operation the cost is likely not that significant. If you think barffing and throwing an exception is better, I would disagree. The consumer bit has to happen either way. It can synthesize the value from the timestamp (if present) if it doesnt have a specific differnet value. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 730893) Time Spent: 6h 40m (was: 6.5h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 6h 40m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730855=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730855 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 12:22 Start Date: 22/Feb/22 12:22 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811888178 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime +message.setJMSDeliveryTime(timeStamp); Review comment: I'm not following you on what the recommended approach here is. You mentioned before that the field is required and should be hydrated with the timestamp value. - ActiveMQ producer message (and foreign v2) needs value for client after message has been processed through the producer - ActiveMQ consumer message (and foreign v2) needs value for client after message has been received To handle a v1 message we'd have to add reflection here and check existence of the field before assignment. That sounds very expensive for every message operation. It would not be safe to cache any of the reflection objects. What am I missing? -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 730855) Time Spent: 6.5h (was: 6h 20m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 6.5h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730849=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730849 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 12:16 Start Date: 22/Feb/22 12:16 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811883242 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime Review comment: Good idea. I'll cross reference both comments and update in the ticket -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 730849) Time Spent: 6h 20m (was: 6h 10m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 6h 20m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730821=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730821 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 11:41 Start Date: 22/Feb/22 11:41 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811856704 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime +message.setJMSDeliveryTime(timeStamp); Review comment: This still seems to be the 'original message' at this point, so note this will throw if it was given a foreign providers JMS 1.1 impl message object, which naturally doesnt implement the method since it doesnt exist for them (remembering back to the previous discussion around why the message set/get methods shouldnt throw UOE to avoid breaking other providers, and how a 2.0 provider can allow working with anothers existing 1.1 messages). -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 730821) Time Spent: 6h 10m (was: 6h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 6h 10m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730820=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730820 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 11:40 Start Date: 22/Feb/22 11:40 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811855690 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1978,17 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); +if (timeToLive > 0) { +expiration = timeToLive + timeStamp; +} + +// TODO: AMQ-8500 - update this when openwire supports JMSDeliveryTime Review comment: Might be good for this comment to reference the ActiveMQMessageTransformation related equivalent to avoid it being forgotten about. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 730820) Time Spent: 6h (was: 5h 50m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: New Feature >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Labels: #jms2 > Fix For: 5.17.0 > > Time Spent: 6h > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730621=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730621 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 02:40 Start Date: 22/Feb/22 02:40 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811533917 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQContext.java ## @@ -0,0 +1,539 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; + +import javax.jms.BytesMessage; +import javax.jms.ConnectionMetaData; +import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.JMSRuntimeException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.jms.StreamMessage; +import javax.jms.TemporaryQueue; +import javax.jms.TemporaryTopic; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import org.apache.activemq.util.JMSExceptionSupport; + +/** + * In terms of the JMS 1.1 API a JMSContext should be thought of as + * representing both a Connection and a Session. Although the simplified + * API removes the need for applications to use those objects, the concepts + * of connection and session remain important. A connection represents a + * physical link to the JMS server and a session represents a + * single-threaded context for sending and receiving messages. + * + * + * @see javax.jms.JMSContext + */ + +public class ActiveMQContext implements JMSContext { + +private static final boolean DEFAULT_AUTO_START = true; + +private final ActiveMQConnection activemqConnection; +private final AtomicLong connectionCounter; +private ActiveMQSession activemqSession = null; + +// Configuration +private boolean autoStart = DEFAULT_AUTO_START; +private final int sessionMode; + +// State +private boolean closeInvoked = false; +private final AtomicBoolean startInvoked = new AtomicBoolean(false); +private ActiveMQMessageProducer activemqMessageProducer = null; + +ActiveMQContext(final ActiveMQConnection activemqConnection) { +this.activemqConnection = activemqConnection; +this.sessionMode = AUTO_ACKNOWLEDGE; +this.connectionCounter = new AtomicLong(1l); +} + +ActiveMQContext(final ActiveMQConnection activemqConnection, final int sessionMode) { +this.activemqConnection = activemqConnection; +this.sessionMode = sessionMode; +this.connectionCounter = new AtomicLong(1l); +} + +private ActiveMQContext(final ActiveMQConnection activemqConnection, final int sessionMode, final AtomicLong connectionCounter) { +this.activemqConnection = activemqConnection; +this.sessionMode = sessionMode; +this.connectionCounter = connectionCounter; +} + +@Override +public JMSContext createContext(int sessionMode) { +if(connectionCounter.get() == 0l) { +throw new JMSRuntimeException("Context already closed"); +} + +connectionCounter.incrementAndGet(); +return new ActiveMQContext(activemqConnection, sessionMode, connectionCounter); +} + +@Override +public JMSProducer createProducer() { +return new ActiveMQProducer(this, getCreatedActiveMQMessageProducer()); +} + +@Override +public String getClientID() { +try { +return this.activemqConnection.getClientID(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730620=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730620 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 02:39 Start Date: 22/Feb/22 02:39 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811533701 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQContext.java ## @@ -0,0 +1,477 @@ +/** + * 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; + +import java.io.Serializable; + +import javax.jms.BytesMessage; +import javax.jms.ConnectionMetaData; +import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.JMSRuntimeException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.jms.StreamMessage; +import javax.jms.TemporaryQueue; +import javax.jms.TemporaryTopic; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import org.apache.activemq.util.JMSExceptionSupport; + +/** + * In terms of the JMS 1.1 API a JMSContext should be thought of as + * representing both a Connection and a Session. Although the simplified + * API removes the need for applications to use those objects, the concepts + * of connection and session remain important. A connection represents a + * physical link to the JMS server and a session represents a + * single-threaded context for sending and receiving messages. + * + * + * @see javax.jms.JMSContext + */ + +public class ActiveMQContext implements JMSContext { + +private static final boolean DEFAULT_AUTO_START = true; + +private final ActiveMQConnection activemqConnection; +private ActiveMQSession activemqSession = null; + +// Configuration +private boolean autoStart = DEFAULT_AUTO_START; Review comment: This is completed ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQConsumer.java ## @@ -0,0 +1,106 @@ +/** + * 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; + +import javax.jms.JMSConsumer; +import javax.jms.JMSException; +import javax.jms.JMSRuntimeException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; + +import org.apache.activemq.util.JMSExceptionSupport; + +public class ActiveMQConsumer implements JMSConsumer { + +private final ActiveMQContext activemqContext; +private final MessageConsumer activemqMessageConsumer; + +ActiveMQConsumer(ActiveMQContext activemqContext, MessageConsumer activemqMessageConsumer) { +this.activemqContext = activemqContext; +this.activemqMessageConsumer = activemqMessageConsumer; +} + +@Override +public String getMessageSelector() { Review comment: This is completed ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQConsumer.java ## @@ -0,0 +1,106 @@ +/** + * Licensed to the
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730618=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730618 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 02:39 Start Date: 22/Feb/22 02:39 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811521072 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730617=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730617 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 02:38 Start Date: 22/Feb/22 02:38 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811533284 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730614=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730614 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 02:37 Start Date: 22/Feb/22 02:37 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811533094 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQContext.java ## @@ -0,0 +1,477 @@ +/** + * 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; + +import java.io.Serializable; + +import javax.jms.BytesMessage; +import javax.jms.ConnectionMetaData; +import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.JMSRuntimeException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.jms.StreamMessage; +import javax.jms.TemporaryQueue; +import javax.jms.TemporaryTopic; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import org.apache.activemq.util.JMSExceptionSupport; + +/** + * In terms of the JMS 1.1 API a JMSContext should be thought of as + * representing both a Connection and a Session. Although the simplified + * API removes the need for applications to use those objects, the concepts + * of connection and session remain important. A connection represents a + * physical link to the JMS server and a session represents a + * single-threaded context for sending and receiving messages. + * + * + * @see javax.jms.JMSContext + */ + +public class ActiveMQContext implements JMSContext { + +private static final boolean DEFAULT_AUTO_START = true; + +private final ActiveMQConnection activemqConnection; +private ActiveMQSession activemqSession = null; + +// Configuration +private boolean autoStart = DEFAULT_AUTO_START; +private final int sessionMode; + +// State +private boolean closeInvoked = false; +private ActiveMQMessageProducer activemqMessageProducer = null; + +ActiveMQContext(final ActiveMQConnection activemqConnection) { +this.activemqConnection = activemqConnection; +this.sessionMode = AUTO_ACKNOWLEDGE; +} + +ActiveMQContext(final ActiveMQConnection activemqConnection, final int sessionMode) { +this.activemqConnection = activemqConnection; +this.sessionMode = sessionMode; +} + +@Override +public JMSContext createContext(int sessionMode) { +return new ActiveMQContext(activemqConnection, sessionMode); +} + +@Override +public JMSProducer createProducer() { +return new ActiveMQProducer(this, getCreatedActiveMQMessageProducer()); +} + +@Override +public String getClientID() { +try { +return this.activemqConnection.getClientID(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public void setClientID(String clientID) { +try { +this.activemqConnection.setClientID(clientID); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public ConnectionMetaData getMetaData() { +checkContextState(); +try { +return this.activemqConnection.getMetaData(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public ExceptionListener getExceptionListener() { +checkContextState(); +try { +return this.activemqConnection.getExceptionListener(); +} catch (JMSException e) { +throw
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730615=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730615 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 02:37 Start Date: 22/Feb/22 02:37 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811533151 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730605=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730605 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 02:08 Start Date: 22/Feb/22 02:08 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811523178 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730603=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730603 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 02:01 Start Date: 22/Feb/22 02:01 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811521072 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730604=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730604 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 22/Feb/22 02:01 Start Date: 22/Feb/22 02:01 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811521230 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key,
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730558=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730558 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 21/Feb/22 22:19 Start Date: 21/Feb/22 22:19 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811455191 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730557=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730557 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 21/Feb/22 22:18 Start Date: 21/Feb/22 22:18 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811454975 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730546=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730546 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 21/Feb/22 21:26 Start Date: 21/Feb/22 21:26 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811436125 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key,
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730547=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730547 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 21/Feb/22 21:26 Start Date: 21/Feb/22 21:26 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811436125 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key,
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730542=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730542 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 21/Feb/22 21:21 Start Date: 21/Feb/22 21:21 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811434203 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730526=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730526 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 21/Feb/22 20:29 Start Date: 21/Feb/22 20:29 Worklog Time Spent: 10m Work Description: tabish121 commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811412971 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730515=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730515 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 21/Feb/22 19:54 Start Date: 21/Feb/22 19:54 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792170430 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730513=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730513 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 21/Feb/22 19:52 Start Date: 21/Feb/22 19:52 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r807196409 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=730332=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-730332 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 21/Feb/22 12:21 Start Date: 21/Feb/22 12:21 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r811047310 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java ## @@ -1956,12 +1976,15 @@ protected void send(ActiveMQMessageProducer producer, ActiveMQDestination destin //Set the "JMS" header fields on the original message, see 1.1 spec section 3.4.11 message.setJMSDeliveryMode(deliveryMode); long expiration = 0L; -if (!producer.getDisableMessageTimestamp()) { -long timeStamp = System.currentTimeMillis(); +long timeStamp = System.currentTimeMillis(); Review comment: It should also populate the JMSDeliveryTime value since thats a mandatory header (with the timestamp value at first, and later the actual delayed delivery time when delivery-delay support is added), doesnt look like that is happening. ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715706=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715706 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 26/Jan/22 14:14 Start Date: 26/Jan/22 14:14 Worklog Time Spent: 10m Work Description: cshannon commented on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1022236383 @mattrpav - it would probably make sense to take a look at Qpid JMS and Artemis implementations for the JMS 2.0 api. You can probably just copy a lot of what they did for JmsProducer, JmsConsumer, etc. For example: https://github.com/apache/qpid-jms/blob/main/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsProducer.java -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 715706) Time Spent: 2h 50m (was: 2h 40m) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: Sub-task >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Time Spent: 2h 50m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715643=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715643 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 26/Jan/22 12:26 Start Date: 26/Jan/22 12:26 Worklog Time Spent: 10m Work Description: gemmellr commented on pull request #729: URL: https://github.com/apache/activemq/pull/729#issuecomment-1022151804 I also skimmed it and noted some things, replied to some of the comments on Tim's review. Even for a first phase it seems pretty raw/incomplete at this point, and I'd echo the near total lack of tests giving little confidence. Especially given discussion of including it in releases in a week or two, when that release has been getting promised 'soon' to folks on the users list since 2020. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 715643) Time Spent: 2h 40m (was: 2.5h) > Implement JMS 2.0 Connection createContext methods > -- > > Key: AMQ-8322 > URL: https://issues.apache.org/jira/browse/AMQ-8322 > Project: ActiveMQ > Issue Type: Sub-task >Reporter: Matt Pavlovich >Assignee: Matt Pavlovich >Priority: Major > Time Spent: 2h 40m > Remaining Estimate: 0h > > Add support for JMSContext, JMSProducer and JMSConsumer for working with > queues -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715621=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715621 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 26/Jan/22 12:10 Start Date: 26/Jan/22 12:10 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792574207 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key,
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715619=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715619 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 26/Jan/22 12:07 Start Date: 26/Jan/22 12:07 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792571836 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(messageProperties != null && !messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key,
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715618=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715618 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 26/Jan/22 11:55 Start Date: 26/Jan/22 11:55 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792562889 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715609=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715609 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 26/Jan/22 11:31 Start Date: 26/Jan/22 11:31 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792545869 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715608=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715608 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 26/Jan/22 11:30 Start Date: 26/Jan/22 11:30 Worklog Time Spent: 10m Work Description: gemmellr commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792545446 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715346=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715346 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Jan/22 22:27 Start Date: 25/Jan/22 22:27 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792170719 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715345=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715345 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Jan/22 22:25 Start Date: 25/Jan/22 22:25 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792170719 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715344=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715344 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Jan/22 22:25 Start Date: 25/Jan/22 22:25 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792170430 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715343=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715343 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Jan/22 22:24 Start Date: 25/Jan/22 22:24 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792169822 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQProducer.java ## @@ -0,0 +1,547 @@ +/** + * 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; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.jms.BytesMessage; +import javax.jms.CompletionListener; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageFormatRuntimeException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.TextMessage; + +import org.apache.activemq.util.JMSExceptionSupport; +import org.apache.activemq.util.TypeConversionSupport; + +public class ActiveMQProducer implements JMSProducer { + +private final ActiveMQContext activemqContext; +private final MessageProducer activemqMessageProducer; + +// QoS override of defaults on a per-JMSProducer instance basis +private String correlationId = null; +private byte[] correlationIdBytes = null; +private Long deliveryDelay = null; +private Integer deliveryMode = null; +private Integer priority = null; +private Destination replyTo = null; +private Long timeToLive = null; +private String type = null; + +// Properties applied to all messages on a per-JMS producer instance basis +private Map messageProperties = null; + +ActiveMQProducer(ActiveMQContext activemqContext, MessageProducer activemqMessageProducer) { +this.activemqContext = activemqContext; +this.activemqMessageProducer = activemqMessageProducer; +} + +@Override +public JMSProducer send(Destination destination, Message message) { +try { +if(this.correlationId != null) { +message.setJMSCorrelationID(this.correlationId); +} + +if(this.correlationIdBytes != null) { +message.setJMSCorrelationIDAsBytes(this.correlationIdBytes); +} + +if(this.replyTo != null) { +message.setJMSReplyTo(this.replyTo); +} + +if(this.type != null) { +message.setJMSType(this.type); +} + +if(!messageProperties.isEmpty()) { +for(Map.Entry propertyEntry : messageProperties.entrySet()) { +message.setObjectProperty(propertyEntry.getKey(), propertyEntry.getValue()); +} +} + +activemqMessageProducer.send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +return this; +} + +@Override +public JMSProducer send(Destination destination, String body) { +TextMessage textMessage = activemqContext.createTextMessage(body); +send(destination, textMessage); +return this; +} + +@Override +public JMSProducer send(Destination destination, Map body) { +MapMessage mapMessage = activemqContext.createMapMessage(); + +if (body != null) { +try { + for (Map.Entry mapEntry : body.entrySet()) { + final String key = mapEntry.getKey(); + final Object value = mapEntry.getValue(); + final Class valueObject = value.getClass(); + if (String.class.isAssignableFrom(valueObject)) { + mapMessage.setString(key, String.class.cast(value)); +
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715341=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715341 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Jan/22 22:12 Start Date: 25/Jan/22 22:12 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792163073 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQContext.java ## @@ -0,0 +1,477 @@ +/** + * 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; + +import java.io.Serializable; + +import javax.jms.BytesMessage; +import javax.jms.ConnectionMetaData; +import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.IllegalStateRuntimeException; +import javax.jms.JMSConsumer; +import javax.jms.JMSContext; +import javax.jms.JMSException; +import javax.jms.JMSProducer; +import javax.jms.JMSRuntimeException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.jms.StreamMessage; +import javax.jms.TemporaryQueue; +import javax.jms.TemporaryTopic; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import org.apache.activemq.util.JMSExceptionSupport; + +/** + * In terms of the JMS 1.1 API a JMSContext should be thought of as + * representing both a Connection and a Session. Although the simplified + * API removes the need for applications to use those objects, the concepts + * of connection and session remain important. A connection represents a + * physical link to the JMS server and a session represents a + * single-threaded context for sending and receiving messages. + * + * + * @see javax.jms.JMSContext + */ + +public class ActiveMQContext implements JMSContext { + +private static final boolean DEFAULT_AUTO_START = true; + +private final ActiveMQConnection activemqConnection; +private ActiveMQSession activemqSession = null; + +// Configuration +private boolean autoStart = DEFAULT_AUTO_START; +private final int sessionMode; + +// State +private boolean closeInvoked = false; +private ActiveMQMessageProducer activemqMessageProducer = null; + +ActiveMQContext(final ActiveMQConnection activemqConnection) { +this.activemqConnection = activemqConnection; +this.sessionMode = AUTO_ACKNOWLEDGE; +} + +ActiveMQContext(final ActiveMQConnection activemqConnection, final int sessionMode) { +this.activemqConnection = activemqConnection; +this.sessionMode = sessionMode; +} + +@Override +public JMSContext createContext(int sessionMode) { +return new ActiveMQContext(activemqConnection, sessionMode); +} + +@Override +public JMSProducer createProducer() { +return new ActiveMQProducer(this, getCreatedActiveMQMessageProducer()); +} + +@Override +public String getClientID() { +try { +return this.activemqConnection.getClientID(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public void setClientID(String clientID) { +try { +this.activemqConnection.setClientID(clientID); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public ConnectionMetaData getMetaData() { +checkContextState(); +try { +return this.activemqConnection.getMetaData(); +} catch (JMSException e) { +throw JMSExceptionSupport.convertToJMSRuntimeException(e); +} +} + +@Override +public ExceptionListener getExceptionListener() { +checkContextState(); +try { +return this.activemqConnection.getExceptionListener(); +} catch (JMSException e) { +throw
[jira] [Work logged] (AMQ-8322) Implement JMS 2.0 Connection createContext methods
[ https://issues.apache.org/jira/browse/AMQ-8322?focusedWorklogId=715331=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-715331 ] ASF GitHub Bot logged work on AMQ-8322: --- Author: ASF GitHub Bot Created on: 25/Jan/22 21:55 Start Date: 25/Jan/22 21:55 Worklog Time Spent: 10m Work Description: mattrpav commented on a change in pull request #729: URL: https://github.com/apache/activemq/pull/729#discussion_r792152293 ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQConsumer.java ## @@ -0,0 +1,106 @@ +/** + * 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; + +import javax.jms.JMSConsumer; +import javax.jms.JMSException; +import javax.jms.JMSRuntimeException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; + +import org.apache.activemq.util.JMSExceptionSupport; + +public class ActiveMQConsumer implements JMSConsumer { + +private final ActiveMQContext activemqContext; +private final MessageConsumer activemqMessageConsumer; + +ActiveMQConsumer(ActiveMQContext activemqContext, MessageConsumer activemqMessageConsumer) { +this.activemqContext = activemqContext; +this.activemqMessageConsumer = activemqMessageConsumer; +} + +@Override +public String getMessageSelector() { +throw new UnsupportedOperationException("getMessageSelector() is not supported"); +} + +@Override +public MessageListener getMessageListener() throws JMSRuntimeException { +throw new UnsupportedOperationException("getMessageListener() is not supported"); Review comment: This will be supported in a follow-on PR aligned with the approach to implement and add tests in phases ## File path: activemq-client/src/main/java/org/apache/activemq/ActiveMQConsumer.java ## @@ -0,0 +1,106 @@ +/** + * 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; + +import javax.jms.JMSConsumer; +import javax.jms.JMSException; +import javax.jms.JMSRuntimeException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; + +import org.apache.activemq.util.JMSExceptionSupport; + +public class ActiveMQConsumer implements JMSConsumer { + +private final ActiveMQContext activemqContext; +private final MessageConsumer activemqMessageConsumer; + +ActiveMQConsumer(ActiveMQContext activemqContext, MessageConsumer activemqMessageConsumer) { +this.activemqContext = activemqContext; +this.activemqMessageConsumer = activemqMessageConsumer; +} + +@Override +public String getMessageSelector() { +throw new UnsupportedOperationException("getMessageSelector() is not supported"); +} + +@Override +public MessageListener getMessageListener() throws JMSRuntimeException { +throw new UnsupportedOperationException("getMessageListener() is not supported"); +} + +@Override +public void setMessageListener(MessageListener listener) throws JMSRuntimeException { +throw new UnsupportedOperationException("setMessageListener(MessageListener) is not supported"); Review comment: This will be supported in a follow-on PR aligned with the approach to implement and add tests in phases ## File path: