This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new a3b74cf306cf fix(components): sjms streams note design
a3b74cf306cf is described below

commit a3b74cf306cf1b5c0fd0ae64dd5575918f176a6d
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Tue Dec 2 09:45:48 2025 +0100

    fix(components): sjms streams note design
---
 .../camel/component/sjms/jms/Jms11ObjectFactory.java      |  3 ++-
 .../apache/camel/component/sjms/jms/JmsObjectFactory.java |  8 ++++++++
 .../camel/component/sjms/SjmsSendDynamicAwareTest.java    | 11 +++++++----
 .../component/sjms/producer/QueueProducerQoSTest.java     | 10 ++--------
 .../sjms/tx/TransactedProducerInOutErrorTest.java         | 15 ++++++++-------
 5 files changed, 27 insertions(+), 20 deletions(-)

diff --git 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/Jms11ObjectFactory.java
 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/Jms11ObjectFactory.java
index c060fea5802a..3c33f7654746 100644
--- 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/Jms11ObjectFactory.java
+++ 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/Jms11ObjectFactory.java
@@ -134,7 +134,8 @@ public class Jms11ObjectFactory implements JmsObjectFactory 
{
             boolean persistent,
             long ttl)
             throws Exception {
-        MessageProducer messageProducer = session.createProducer(destination);
+        // NOTE: the object must be closed byt the client
+        MessageProducer messageProducer = session.createProducer(destination); 
// NOSONAR
         messageProducer.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : 
DeliveryMode.NON_PERSISTENT);
         if (ttl > 0) {
             messageProducer.setTimeToLive(ttl);
diff --git 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/JmsObjectFactory.java
 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/JmsObjectFactory.java
index cf88d9701794..00241545eec9 100644
--- 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/JmsObjectFactory.java
+++ 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/JmsObjectFactory.java
@@ -24,28 +24,36 @@ import jakarta.jms.Session;
 import org.apache.camel.Endpoint;
 
 public interface JmsObjectFactory {
+    // NOTE: client must close the returned resource.
     MessageConsumer createMessageConsumer(Session session, Endpoint endpoint) 
throws Exception;
 
+    // NOTE: client must close the returned resource.
     MessageConsumer createQueueMessageConsumer(Session session, Destination 
destination) throws Exception;
 
+    // NOTE: client must close the returned resource.
     MessageConsumer createMessageConsumer(
             Session session, Destination destination,
             String messageSelector, boolean topic, String subscriptionId, 
boolean durable,
             boolean shared)
             throws Exception;
 
+    // NOTE: client must close the returned resource.
     MessageConsumer createMessageConsumer(
             Session session, Destination destination,
             String messageSelector, boolean topic, String subscriptionId, 
boolean durable,
             boolean shared, boolean noLocal)
             throws Exception;
 
+    // NOTE: client must close the returned resource.
     MessageProducer createMessageProducer(Session session, Endpoint endpoint) 
throws Exception;
 
+    // NOTE: client must close the returned resource.
     MessageProducer createMessageProducer(Session session, Endpoint endpoint, 
String destinationName) throws Exception;
 
+    // NOTE: client must close the returned resource.
     MessageProducer createMessageProducer(Session session, Endpoint endpoint, 
Destination destination) throws Exception;
 
+    // NOTE: client must close the returned resource.
     MessageProducer createMessageProducer(
             Session session, Destination destination,
             boolean persistent, long ttl)
diff --git 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsSendDynamicAwareTest.java
 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsSendDynamicAwareTest.java
index 52d66d656926..dbe3ea763458 100644
--- 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsSendDynamicAwareTest.java
+++ 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/SjmsSendDynamicAwareTest.java
@@ -20,6 +20,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.spi.SendDynamicAware;
 import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.camel.test.junit5.TestSupport;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -36,11 +37,12 @@ public class SjmsSendDynamicAwareTest extends 
CamelTestSupport {
     @Test
     public void testUriParsing() throws Exception {
         this.sjmsSendDynamicAware.setScheme("sjms");
-        Exchange exchange = createExchangeWithBody("The Body");
+        Exchange exchange = TestSupport.createExchangeWithBody(this.context(), 
"The Body");
         SendDynamicAware.DynamicAwareEntry entry
                 = new SendDynamicAware.DynamicAwareEntry(
                         "sjms:destination.SjmsSendDynamicAwareTest", 
"sjms:${header.test}", null, null);
-        Processor processor = 
this.sjmsSendDynamicAware.createPreProcessor(createExchangeWithBody("Body"), 
entry);
+        Processor processor = this.sjmsSendDynamicAware
+                
.createPreProcessor(TestSupport.createExchangeWithBody(this.context(), "Body"), 
entry);
         processor.process(exchange);
         assertEquals("destination.SjmsSendDynamicAwareTest",
                 
exchange.getMessage().getHeader(SjmsConstants.JMS_DESTINATION_NAME));
@@ -49,11 +51,12 @@ public class SjmsSendDynamicAwareTest extends 
CamelTestSupport {
     @Test
     public void testSlashedUriParsing() throws Exception {
         this.sjmsSendDynamicAware.setScheme("sjms");
-        Exchange exchange = createExchangeWithBody("The Body");
+        Exchange exchange = TestSupport.createExchangeWithBody(this.context(), 
"The Body");
         SendDynamicAware.DynamicAwareEntry entry
                 = new SendDynamicAware.DynamicAwareEntry(
                         "sjms://destination.SjmsSendDynamicAwareTest", 
"sjms://${header.test}", null, null);
-        Processor processor = 
this.sjmsSendDynamicAware.createPreProcessor(createExchangeWithBody("Body"), 
entry);
+        Processor processor = this.sjmsSendDynamicAware
+                
.createPreProcessor(TestSupport.createExchangeWithBody(this.context(), "Body"), 
entry);
         processor.process(exchange);
         assertEquals("destination.SjmsSendDynamicAwareTest",
                 
exchange.getMessage().getHeader(SjmsConstants.JMS_DESTINATION_NAME));
diff --git 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
index de971ad5824e..f951d7205239 100644
--- 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
+++ 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
@@ -28,21 +28,16 @@ import org.apache.camel.EndpointInject;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.component.sjms.SjmsComponent;
-import org.apache.camel.component.sjms.jms.DefaultDestinationCreationStrategy;
-import org.apache.camel.component.sjms.jms.DestinationCreationStrategy;
 import 
org.apache.camel.test.infra.artemis.services.ArtemisEmbeddedServiceBuilder;
 import org.apache.camel.test.infra.artemis.services.ArtemisService;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.fail;
 
 public class QueueProducerQoSTest extends CamelTestSupport {
-    private static final Logger LOG = 
LoggerFactory.getLogger(QueueProducerQoSTest.class);
 
     private static final String TEST_INONLY_DESTINATION_NAME = 
"queue.producer.test.qos.inonly.QueueProducerQoSTest";
     private static final String TEST_INOUT_DESTINATION_NAME = 
"queue.producer.test.qos.inout.QueueProducerQoSTest";
@@ -63,7 +58,6 @@ public class QueueProducerQoSTest extends CamelTestSupport {
 
     private Connection connection;
     private Session session;
-    private DestinationCreationStrategy destinationCreationStrategy = new 
DefaultDestinationCreationStrategy();
 
     @Override
     protected CamelContext createCamelContext() throws Exception {
@@ -119,8 +113,8 @@ public class QueueProducerQoSTest extends CamelTestSupport {
     private static Configuration configureArtemis(Configuration configuration) 
{
         return configuration.addAddressSetting("#",
                 new AddressSettings()
-                        
.setDeadLetterAddress(SimpleString.toSimpleString("DLQ"))
-                        
.setExpiryAddress(SimpleString.toSimpleString("ExpiryQueue"))
+                        .setDeadLetterAddress(SimpleString.of("DLQ"))
+                        .setExpiryAddress(SimpleString.of("ExpiryQueue"))
                         .setExpiryDelay(1000L))
                 .setMessageExpiryScanPeriod(500L);
     }
diff --git 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedProducerInOutErrorTest.java
 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedProducerInOutErrorTest.java
index eecb9c6f5fce..0c9343bdf04b 100644
--- 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedProducerInOutErrorTest.java
+++ 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedProducerInOutErrorTest.java
@@ -38,13 +38,14 @@ public class TransactedProducerInOutErrorTest {
 
     @Test
     public void test() throws Exception {
-        CamelContext context = new DefaultCamelContext();
-        context.addRoutes(createRouteBuilder());
-        SjmsComponent component = context.getComponent("sjms", 
SjmsComponent.class);
-        
component.setConnectionFactory(CamelJmsTestHelper.createConnectionFactory());
-        FailedToStartRouteException t = 
assertThrows(FailedToStartRouteException.class, context::start);
-        assertEquals(IllegalArgumentException.class, 
t.getCause().getCause().getClass());
-        LOG.info("Exception was thrown as expected", t);
+        try (CamelContext context = new DefaultCamelContext()) {
+            context.addRoutes(createRouteBuilder());
+            SjmsComponent component = context.getComponent("sjms", 
SjmsComponent.class);
+            
component.setConnectionFactory(CamelJmsTestHelper.createConnectionFactory());
+            FailedToStartRouteException t = 
assertThrows(FailedToStartRouteException.class, context::start);
+            assertEquals(IllegalArgumentException.class, 
t.getCause().getCause().getClass());
+            LOG.info("Exception was thrown as expected", t);
+        }
     }
 
     protected RouteBuilder createRouteBuilder() {

Reply via email to