[ 
https://issues.apache.org/jira/browse/CAMEL-12295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16384875#comment-16384875
 ] 

ASF GitHub Bot commented on CAMEL-12295:
----------------------------------------

aldettinger closed pull request #2238: CAMEL-12295: Added an option to Jms 
Endpoints so that they format JMS…
URL: https://github.com/apache/camel/pull/2238
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/components/camel-amqp/src/main/docs/amqp-component.adoc 
b/components/camel-amqp/src/main/docs/amqp-component.adoc
index 230c7cc2b1c..ff345b2c3f3 100644
--- a/components/camel-amqp/src/main/docs/amqp-component.adoc
+++ b/components/camel-amqp/src/main/docs/amqp-component.adoc
@@ -39,7 +39,7 @@ link:../../../../camel-jms/src/main/docs/readme.html[JMS] 
component after the de
 
 
 // component options: START
-The AMQP component supports 79 options which are listed below.
+The AMQP component supports 80 options which are listed below.
 
 
 
@@ -123,6 +123,7 @@ The AMQP component supports 79 options which are listed 
below.
 | *subscriptionShared* (consumer) | Set whether to make the subscription 
shared. The shared subscription name to be used can be specified through the 
subscriptionName property. Default is false. Set this to true to register a 
shared subscription, typically in combination with a subscriptionName value 
(unless your message listener class name is good enough as subscription name). 
Note that shared subscriptions may also be durable, so this flag can (and often 
will) be combined with subscriptionDurable as well. Only makes sense when 
listening to a topic (pub-sub domain), therefore this method switches the 
pubSubDomain flag as well. Requires a JMS 2.0 compatible message broker. | 
false | boolean
 | *subscriptionName* (consumer) | Set the name of a subscription to create. To 
be applied in case of a topic (pub-sub domain) with a shared or durable 
subscription. The subscription name needs to be unique within this client's JMS 
client id. Default is the class name of the specified message listener. Note: 
Only 1 concurrent consumer (which is the default of this message listener 
container) is allowed for each subscription, except for a shared subscription 
(which requires JMS 2.0). |  | String
 | *streamMessageType Enabled* (producer) | Sets whether StreamMessage type is 
enabled or not. Message payloads of streaming kind such as files, InputStream, 
etc will either by sent as BytesMessage or StreamMessage. This option controls 
which kind will be used. By default BytesMessage is used which enforces the 
entire message payload to be read into memory. By enabling this option the 
message payload is read into memory in chunks and each chunk is then written to 
the StreamMessage until no more data. | false | boolean
+| *formatDateHeadersTo Iso8601* (producer) | Sets whether date headers should 
be formatted according to the ISO 8601 standard. | false | boolean
 | *headerFilterStrategy* (filter) | To use a custom 
org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel 
message. |  | HeaderFilterStrategy
 | *resolveProperty Placeholders* (advanced) | Whether the component should 
resolve property placeholders on itself when starting. Only properties which 
are of String type can use property placeholders. | true | boolean
 |===
@@ -154,7 +155,7 @@ with the following path and query parameters:
 |===
 
 
-==== Query Parameters (90 parameters):
+==== Query Parameters (91 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -193,6 +194,7 @@ with the following path and query parameters:
 | *deliveryMode* (producer) | Specifies the delivery mode to be used. 
Possibles values are those defined by javax.jms.DeliveryMode. NON_PERSISTENT = 
1 and PERSISTENT = 2. |  | Integer
 | *deliveryPersistent* (producer) | Specifies whether persistent delivery is 
used by default. | true | boolean
 | *explicitQosEnabled* (producer) | Set if the deliveryMode, priority or 
timeToLive qualities of service should be used when sending messages. This 
option is based on Spring's JmsTemplate. The deliveryMode, priority and 
timeToLive options are applied to the current endpoint. This contrasts with the 
preserveMessageQos option, which operates at message granularity, reading QoS 
properties exclusively from the Camel In message headers. | false | Boolean
+| *formatDateHeadersToIso8601* (producer) | Sets whether JMS date properties 
should be formatted according to the ISO 8601 standard. | false | boolean
 | *preserveMessageQos* (producer) | Set to true, if you want to send message 
using the QoS settings specified on the message, instead of the QoS settings on 
the JMS endpoint. The following three headers are considered JMSPriority, 
JMSDeliveryMode, and JMSExpiration. You can provide all or only some of them. 
If not provided, Camel will fall back to use the values from the endpoint 
instead. So, when using this option, the headers override the values from the 
endpoint. The explicitQosEnabled option, by contrast, will only use options set 
on the endpoint, and not values from the message header. | false | boolean
 | *priority* (producer) | Values greater than 1 specify the message priority 
when sending (where 0 is the lowest priority and 9 is the highest). The 
explicitQosEnabled option must also be enabled in order for this option to have 
any effect. | 4 | int
 | *replyToConcurrentConsumers* (producer) | Specifies the default number of 
concurrent consumers when doing request/reply over JMS. See also the 
maxMessagesPerTask option to control dynamic scaling up/down of threads. | 1 | 
int
diff --git a/components/camel-jms/pom.xml b/components/camel-jms/pom.xml
index 2e4b7bc09bd..b2a4db13a59 100644
--- a/components/camel-jms/pom.xml
+++ b/components/camel-jms/pom.xml
@@ -164,6 +164,11 @@
       <artifactId>log4j-slf4j-impl</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/components/camel-jms/src/main/docs/jms-component.adoc 
b/components/camel-jms/src/main/docs/jms-component.adoc
index 0fba007a5a1..4d68192a2ff 100644
--- a/components/camel-jms/src/main/docs/jms-component.adoc
+++ b/components/camel-jms/src/main/docs/jms-component.adoc
@@ -198,7 +198,7 @@ about these properties by consulting the relevant Spring 
documentation.
 
 
 // component options: START
-The JMS component supports 79 options which are listed below.
+The JMS component supports 80 options which are listed below.
 
 
 
@@ -282,6 +282,7 @@ The JMS component supports 79 options which are listed 
below.
 | *subscriptionShared* (consumer) | Set whether to make the subscription 
shared. The shared subscription name to be used can be specified through the 
subscriptionName property. Default is false. Set this to true to register a 
shared subscription, typically in combination with a subscriptionName value 
(unless your message listener class name is good enough as subscription name). 
Note that shared subscriptions may also be durable, so this flag can (and often 
will) be combined with subscriptionDurable as well. Only makes sense when 
listening to a topic (pub-sub domain), therefore this method switches the 
pubSubDomain flag as well. Requires a JMS 2.0 compatible message broker. | 
false | boolean
 | *subscriptionName* (consumer) | Set the name of a subscription to create. To 
be applied in case of a topic (pub-sub domain) with a shared or durable 
subscription. The subscription name needs to be unique within this client's JMS 
client id. Default is the class name of the specified message listener. Note: 
Only 1 concurrent consumer (which is the default of this message listener 
container) is allowed for each subscription, except for a shared subscription 
(which requires JMS 2.0). |  | String
 | *streamMessageType Enabled* (producer) | Sets whether StreamMessage type is 
enabled or not. Message payloads of streaming kind such as files, InputStream, 
etc will either by sent as BytesMessage or StreamMessage. This option controls 
which kind will be used. By default BytesMessage is used which enforces the 
entire message payload to be read into memory. By enabling this option the 
message payload is read into memory in chunks and each chunk is then written to 
the StreamMessage until no more data. | false | boolean
+| *formatDateHeadersTo Iso8601* (producer) | Sets whether date headers should 
be formatted according to the ISO 8601 standard. | false | boolean
 | *headerFilterStrategy* (filter) | To use a custom 
org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel 
message. |  | HeaderFilterStrategy
 | *resolveProperty Placeholders* (advanced) | Whether the component should 
resolve property placeholders on itself when starting. Only properties which 
are of String type can use property placeholders. | true | boolean
 |===
@@ -324,7 +325,7 @@ with the following path and query parameters:
 |===
 
 
-==== Query Parameters (90 parameters):
+==== Query Parameters (91 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -363,6 +364,7 @@ with the following path and query parameters:
 | *deliveryMode* (producer) | Specifies the delivery mode to be used. 
Possibles values are those defined by javax.jms.DeliveryMode. NON_PERSISTENT = 
1 and PERSISTENT = 2. |  | Integer
 | *deliveryPersistent* (producer) | Specifies whether persistent delivery is 
used by default. | true | boolean
 | *explicitQosEnabled* (producer) | Set if the deliveryMode, priority or 
timeToLive qualities of service should be used when sending messages. This 
option is based on Spring's JmsTemplate. The deliveryMode, priority and 
timeToLive options are applied to the current endpoint. This contrasts with the 
preserveMessageQos option, which operates at message granularity, reading QoS 
properties exclusively from the Camel In message headers. | false | Boolean
+| *formatDateHeadersToIso8601* (producer) | Sets whether date headers should 
be formatted according to the ISO 8601 standard. | false | boolean
 | *preserveMessageQos* (producer) | Set to true, if you want to send message 
using the QoS settings specified on the message, instead of the QoS settings on 
the JMS endpoint. The following three headers are considered JMSPriority, 
JMSDeliveryMode, and JMSExpiration. You can provide all or only some of them. 
If not provided, Camel will fall back to use the values from the endpoint 
instead. So, when using this option, the headers override the values from the 
endpoint. The explicitQosEnabled option, by contrast, will only use options set 
on the endpoint, and not values from the message header. | false | boolean
 | *priority* (producer) | Values greater than 1 specify the message priority 
when sending (where 0 is the lowest priority and 9 is the highest). The 
explicitQosEnabled option must also be enabled in order for this option to have 
any effect. | 4 | int
 | *replyToConcurrentConsumers* (producer) | Specifies the default number of 
concurrent consumers when doing request/reply over JMS. See also the 
maxMessagesPerTask option to control dynamic scaling up/down of threads. | 1 | 
int
diff --git 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
index 0de72fe4395..c9c781a1b3f 100644
--- 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
+++ 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
@@ -24,6 +24,8 @@
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.nio.ByteBuffer;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -488,7 +490,11 @@ protected Object getValidJMSHeaderValue(String headerName, 
Object headerValue) {
         } else if (headerValue instanceof Boolean) {
             return headerValue;
         } else if (headerValue instanceof Date) {
-            return headerValue.toString();
+            if 
(this.endpoint.getConfiguration().isFormatDateHeadersToIso8601()) {
+                return 
ZonedDateTime.ofInstant(((Date)headerValue).toInstant(), 
ZoneOffset.UTC).toString();
+            } else {
+                return headerValue.toString();
+            }
         }
         return null;
     }
diff --git 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
index 134f8fa277d..b8b2d6a5141 100644
--- 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
+++ 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
@@ -1232,6 +1232,22 @@ public void setStreamMessageTypeEnabled(boolean 
streamMessageTypeEnabled) {
         
getConfiguration().setStreamMessageTypeEnabled(streamMessageTypeEnabled);
     }
 
+    /**
+     * Gets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    public boolean isFormatDateHeadersToIso8601() {
+        return getConfiguration().isFormatDateHeadersToIso8601();
+    }
+
+    /**
+     * Sets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    @Metadata(label = "producer", description = "Sets whether date headers 
should be formatted according to the ISO 8601 standard.")
+    public void setFormatDateHeadersToIso8601(boolean 
formatDateHeadersToIso8601) {
+        
getConfiguration().setFormatDateHeadersToIso8601(formatDateHeadersToIso8601);
+    }
 
     // Implementation methods
     // 
-------------------------------------------------------------------------
diff --git 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
index f67a7b800c6..8a471b999ae 100644
--- 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
+++ 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
@@ -491,6 +491,9 @@
         + " By enabling this option the message payload is read into memory in 
chunks and each chunk is then written to the StreamMessage until no more data.")
     private boolean streamMessageTypeEnabled;
 
+    @UriParam(label = "producer", description = "Sets whether JMS date 
properties should be formatted according to the ISO 8601 standard.")
+    private boolean formatDateHeadersToIso8601;
+
     public JmsConfiguration() {
     }
 
@@ -2213,4 +2216,21 @@ public boolean isStreamMessageTypeEnabled() {
     public void setStreamMessageTypeEnabled(boolean streamMessageTypeEnabled) {
         this.streamMessageTypeEnabled = streamMessageTypeEnabled;
     }
+
+    /**
+     * Gets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    public boolean isFormatDateHeadersToIso8601() {
+        return formatDateHeadersToIso8601;
+    }
+
+    /**
+     * Sets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    public void setFormatDateHeadersToIso8601(boolean 
formatDateHeadersToIso8601) {
+        this.formatDateHeadersToIso8601 = formatDateHeadersToIso8601;
+    }
+
 }
diff --git 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
index 3f87f977ca0..4d0e1470caf 100644
--- 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
+++ 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
@@ -1332,6 +1332,16 @@ public void 
setWaitForProvisionCorrelationToBeUpdatedThreadSleepingTime(long sle
         
configuration.setWaitForProvisionCorrelationToBeUpdatedThreadSleepingTime(sleepingTime);
     }
 
+    @ManagedAttribute
+    public boolean isFormatDateHeadersToIso8601() {
+        return configuration.isFormatDateHeadersToIso8601();
+    }
+
+    @ManagedAttribute
+    public void setFormatDateHeadersToIso8601(boolean 
formatDateHeadersToIso8601) {
+        
configuration.setFormatDateHeadersToIso8601(formatDateHeadersToIso8601);
+    }
+
     // Implementation methods
     //-------------------------------------------------------------------------
 
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
index 9beb20a7a20..4efeb3fcbfa 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsBindingTest.java
@@ -18,32 +18,69 @@
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.time.Instant;
+import java.util.Date;
 
 import org.apache.activemq.command.ActiveMQBlobMessage;
+import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.when;
 
+@RunWith(MockitoJUnitRunner.class)
 public class JmsBindingTest {
 
+    private final Instant instant = Instant.ofEpochMilli(1519672338000L);
+
+    @Mock
+    private JmsConfiguration mockJmsConfiguration;
+    @Mock
+    private JmsEndpoint mockJmsEndpoint;
+
+    private JmsBinding jmsBindingUnderTest;
+
+    @Before
+    public void setup() {
+        
when(mockJmsConfiguration.isFormatDateHeadersToIso8601()).thenReturn(false);
+        when(mockJmsConfiguration.isMapJmsMessage()).thenReturn(true);
+        
when(mockJmsEndpoint.getConfiguration()).thenReturn(mockJmsConfiguration);
+        jmsBindingUnderTest = new JmsBinding(mockJmsEndpoint);
+    }
+
     @Test
-    public void testJmsBindingNoArgs() throws Exception {
-        JmsBinding underTest = new JmsBinding();
-        assertNull(underTest.extractBodyFromJms(null, new 
ActiveMQBlobMessage()));
+    public void testExtractNullBodyFromJmsShouldReturnNull() throws Exception {
+        assertNull(jmsBindingUnderTest.extractBodyFromJms(null, new 
ActiveMQBlobMessage()));
     }
 
     @Test
-    public void testGetValidJmsHeaderValueWithBigInteger() {
-        JmsBinding binding = new JmsBinding();
-        Object value = binding.getValidJMSHeaderValue("foo", new 
BigInteger("12345"));
+    public void testGetValidJmsHeaderValueWithBigIntegerShouldSucceed() {
+        Object value = jmsBindingUnderTest.getValidJMSHeaderValue("foo", new 
BigInteger("12345"));
         assertEquals("12345", value);
     }
 
     @Test
-    public void testGetValidJmsHeaderValueWithBigDecimal() {
-        JmsBinding binding = new JmsBinding();
-        Object value = binding.getValidJMSHeaderValue("foo", new 
BigDecimal("123.45"));
+    public void testGetValidJmsHeaderValueWithBigDecimalShouldSucceed() {
+        Object value = jmsBindingUnderTest.getValidJMSHeaderValue("foo", new 
BigDecimal("123.45"));
         assertEquals("123.45", value);
     }
+
+    @Test
+    public void testGetValidJmsHeaderValueWithDateShouldSucceed() {
+        Object value = jmsBindingUnderTest.getValidJMSHeaderValue("foo", 
Date.from(instant));
+        assertNotNull(value);
+        // We can't assert further as the returned value is bound to the 
machine time zone and locale
+    }
+
+    @Test
+    public void testGetValidJmsHeaderValueWithIso8601DateShouldSucceed() {
+        
when(mockJmsConfiguration.isFormatDateHeadersToIso8601()).thenReturn(true);
+        Object value = jmsBindingUnderTest.getValidJMSHeaderValue("foo", 
Date.from(instant));
+        assertEquals("2018-02-26T19:12:18Z", value);
+    }
 }
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
index cded4293d9c..8f7524de25b 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsComponentTest.java
@@ -48,7 +48,7 @@ public void testComponentOptions() throws Exception {
         assertEquals(true, endpoint.isDeliveryPersistent());
         assertEquals(true, endpoint.isExplicitQosEnabled());
         assertEquals(20, endpoint.getIdleTaskExecutionLimit());
-        assertEquals(21, endpoint.getIdleConsumerLimit());        
+        assertEquals(21, endpoint.getIdleConsumerLimit());
         assertEquals(5, endpoint.getMaxConcurrentConsumers());
         assertEquals(90, endpoint.getMaxMessagesPerTask());
         assertEquals(3, endpoint.getPriority());
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
index 8274d452ac6..4d61cb865eb 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java
@@ -354,6 +354,7 @@ public void testDefaultEndpointOptions() throws Exception {
         assertFalse(endpoint.isTransferException());
         assertFalse(endpoint.isTransactedInOut());
         assertFalse(endpoint.isTransferException());
+        assertFalse(endpoint.isFormatDateHeadersToIso8601());
     }
 
     @SuppressWarnings("deprecation")
@@ -491,6 +492,9 @@ public void handleError(Throwable t) {
 
         endpoint.setJmsMessageType(JmsMessageType.Text);
         assertEquals(JmsMessageType.Text, endpoint.getJmsMessageType());
+
+        endpoint.setFormatDateHeadersToIso8601(true);
+        assertTrue(endpoint.isFormatDateHeadersToIso8601());
     }
 
     protected void assertCacheLevel(JmsEndpoint endpoint, int expected) throws 
Exception {
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsFormatDateHeadersToIso8601Test.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsFormatDateHeadersToIso8601Test.java
new file mode 100644
index 00000000000..f67ae4146dd
--- /dev/null
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsFormatDateHeadersToIso8601Test.java
@@ -0,0 +1,68 @@
+/**
+ * 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.camel.component.jms;
+
+import java.time.Instant;
+import java.util.Date;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static 
org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+public class JmsFormatDateHeadersToIso8601Test extends CamelTestSupport {
+
+    private static final Date DATE = 
Date.from(Instant.ofEpochMilli(1519672338000L));
+
+    @Test
+    public void testComponentFormatDateHeaderToIso8601() throws Exception {
+        String outDate = 
template.requestBodyAndHeader("direct:start-isoformat", "body", "date", DATE, 
String.class);
+        assertEquals(outDate, "2018-02-26T19:12:18Z");
+    }
+
+    @Test
+    public void testBindingFormatDateHeaderToIso8601() throws Exception {
+        String outDate = 
template.requestBodyAndHeader("direct:start-nonisoformat", "body", "date", 
DATE, String.class);
+        assertNotEquals(outDate, "2018-02-26T19:12:18Z");
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        ConnectionFactory connectionFactory = 
CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent jms = jmsComponentAutoAcknowledge(connectionFactory);
+        jms.setFormatDateHeadersToIso8601(true);
+        camelContext.addComponent("activemq", jms);
+        return camelContext;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start-isoformat").to("activemq:queue:foo");
+                
from("direct:start-nonisoformat").to("activemq:queue:foo?formatDateHeadersToIso8601=false");
+                
from("activemq:queue:foo").setBody(simple("${in.header.date}"));
+            }
+        };
+    }
+}
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsStreamMessageTypeTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsStreamMessageTypeTest.java
index 3ebffc08ce6..263ea2edbad 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsStreamMessageTypeTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsStreamMessageTypeTest.java
@@ -36,6 +36,7 @@ public void setUp() throws Exception {
         super.setUp();
     }
 
+    @Override
     protected CamelContext createCamelContext() throws Exception {
         CamelContext camelContext = super.createCamelContext();
 
diff --git 
a/platforms/spring-boot/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
 
b/platforms/spring-boot/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
index 1881a30b053..26c8a43974f 100644
--- 
a/platforms/spring-boot/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
+++ 
b/platforms/spring-boot/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
@@ -607,6 +607,11 @@
      * the StreamMessage until no more data.
      */
     private Boolean streamMessageTypeEnabled = false;
+    /**
+     * Sets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    private Boolean formatDateHeadersToIso8601 = false;
     /**
      * To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter
      * header to and from Camel message.
@@ -1249,6 +1254,14 @@ public void setStreamMessageTypeEnabled(Boolean 
streamMessageTypeEnabled) {
         this.streamMessageTypeEnabled = streamMessageTypeEnabled;
     }
 
+    public Boolean getFormatDateHeadersToIso8601() {
+        return formatDateHeadersToIso8601;
+    }
+
+    public void setFormatDateHeadersToIso8601(Boolean 
formatDateHeadersToIso8601) {
+        this.formatDateHeadersToIso8601 = formatDateHeadersToIso8601;
+    }
+
     public HeaderFilterStrategy getHeaderFilterStrategy() {
         return headerFilterStrategy;
     }
diff --git 
a/platforms/spring-boot/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
 
b/platforms/spring-boot/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
index b14cba7a50d..1418504053e 100644
--- 
a/platforms/spring-boot/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
+++ 
b/platforms/spring-boot/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
@@ -610,6 +610,11 @@
      * the StreamMessage until no more data.
      */
     private Boolean streamMessageTypeEnabled = false;
+    /**
+     * Sets whether date headers should be formatted according to the ISO 8601
+     * standard.
+     */
+    private Boolean formatDateHeadersToIso8601 = false;
     /**
      * To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter
      * header to and from Camel message.
@@ -1253,6 +1258,14 @@ public void setStreamMessageTypeEnabled(Boolean 
streamMessageTypeEnabled) {
         this.streamMessageTypeEnabled = streamMessageTypeEnabled;
     }
 
+    public Boolean getFormatDateHeadersToIso8601() {
+        return formatDateHeadersToIso8601;
+    }
+
+    public void setFormatDateHeadersToIso8601(Boolean 
formatDateHeadersToIso8601) {
+        this.formatDateHeadersToIso8601 = formatDateHeadersToIso8601;
+    }
+
     public HeaderFilterStrategy getHeaderFilterStrategy() {
         return headerFilterStrategy;
     }
@@ -1948,6 +1961,11 @@ public void setResolvePropertyPlaceholders(
          * chunk is then written to the StreamMessage until no more data.
          */
         private Boolean streamMessageTypeEnabled = false;
+        /**
+         * Sets whether date headers should be formatted according to the ISO
+         * 8601 standard.
+         */
+        private Boolean formatDateHeadersToIso8601 = false;
 
         public ConsumerType getConsumerType() {
             return consumerType;
@@ -2702,5 +2720,14 @@ public Boolean getStreamMessageTypeEnabled() {
         public void setStreamMessageTypeEnabled(Boolean 
streamMessageTypeEnabled) {
             this.streamMessageTypeEnabled = streamMessageTypeEnabled;
         }
+
+        public Boolean getFormatDateHeadersToIso8601() {
+            return formatDateHeadersToIso8601;
+        }
+
+        public void setFormatDateHeadersToIso8601(
+                Boolean formatDateHeadersToIso8601) {
+            this.formatDateHeadersToIso8601 = formatDateHeadersToIso8601;
+        }
     }
 }
\ No newline at end of file


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Add an option to Jms Endpoints so that they format JMS date properties 
> according to the ISO 8601 standard
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-12295
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12295
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-jms
>            Reporter: Alex Dettinger
>            Assignee: Alex Dettinger
>            Priority: Minor
>             Fix For: 2.21.0
>
>
> Find the inception context in [this 
> discussion|http://camel.465427.n5.nabble.com/JMS-override-Camel-header-type-conversions-td5817516.html].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to