Class JmsBinding
java.lang.Object
org.apache.camel.component.sjms.jms.JmsBinding
A Strategy used to convert between a Camel
Exchange
and Message
to
and from a JMS Message
-
Constructor Summary
ConstructorDescriptionJmsBinding
(boolean mapJmsMessage, boolean allowNullBody, org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy, JmsKeyFormatStrategy jmsJmsKeyFormatStrategy, MessageCreatedStrategy messageCreatedStrategy) -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendJmsProperties
(jakarta.jms.Message jmsMessage, org.apache.camel.Exchange exchange, Map<String, Object> headers) Appends the JMS headers from the CamelMessage
void
appendJmsProperty
(jakarta.jms.Message jmsMessage, org.apache.camel.Exchange exchange, String headerName, Object headerValue) protected byte[]
createByteArrayFromBytesMessage
(jakarta.jms.BytesMessage message) protected jakarta.jms.Message
createJmsMessage
(Exception cause, jakarta.jms.Session session) protected jakarta.jms.Message
createJmsMessage
(org.apache.camel.Exchange exchange, Object body, Map<String, Object> headers, jakarta.jms.Session session, org.apache.camel.CamelContext context) protected jakarta.jms.Message
createJmsMessageForType
(org.apache.camel.Exchange exchange, Object body, jakarta.jms.Session session, org.apache.camel.CamelContext context, JmsMessageType type) Create theMessage
createMapFromMapMessage
(jakarta.jms.MapMessage message) Extracts aMap
from aMapMessage
extractBodyFromJms
(org.apache.camel.Exchange exchange, jakarta.jms.Message message) Extracts the body from the JMS messageextractHeadersFromJms
(jakarta.jms.Message jmsMessage, org.apache.camel.Exchange exchange) protected JmsMessageType
getJMSMessageTypeForBody
(org.apache.camel.Exchange exchange, Object body, Map<String, Object> headers, jakarta.jms.Session session, org.apache.camel.CamelContext context) Return theJmsMessageType
getObjectProperty
(jakarta.jms.Message jmsMessage, String name) protected Object
getValidJMSHeaderValue
(String headerName, Object headerValue) Strategy to test if the given header is valid according to the JMS spec to be set as a property on the JMS message.protected boolean
isStandardJMSHeader
(String headerName) Is the given header a standard JMS headerjakarta.jms.Message
makeJmsMessage
(org.apache.camel.Exchange exchange, org.apache.camel.Message camelMessage, jakarta.jms.Session session, Exception cause) Creates a JMS message from the Camel exchange and messageprotected void
populateMapMessage
(jakarta.jms.MapMessage message, Map<?, ?> map, org.apache.camel.CamelContext context) Populates aMapMessage
from aMap
instance.protected boolean
shouldOutputHeader
(String headerName, Object headerValue, org.apache.camel.Exchange exchange) Strategy to allow filtering of headers which are put on the JMS message
-
Constructor Details
-
JmsBinding
public JmsBinding(boolean mapJmsMessage, boolean allowNullBody, org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy, JmsKeyFormatStrategy jmsJmsKeyFormatStrategy, MessageCreatedStrategy messageCreatedStrategy)
-
-
Method Details
-
extractBodyFromJms
Extracts the body from the JMS message- Parameters:
exchange
- the exchangemessage
- the message to extract its body- Returns:
- the body, can be null
-
extractHeadersFromJms
-
getObjectProperty
public Object getObjectProperty(jakarta.jms.Message jmsMessage, String name) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
createByteArrayFromBytesMessage
protected byte[] createByteArrayFromBytesMessage(jakarta.jms.BytesMessage message) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
makeJmsMessage
public jakarta.jms.Message makeJmsMessage(org.apache.camel.Exchange exchange, org.apache.camel.Message camelMessage, jakarta.jms.Session session, Exception cause) throws jakarta.jms.JMSException Creates a JMS message from the Camel exchange and message- Parameters:
exchange
- the current exchangecamelMessage
- the body to make a jakarta.jms.Message assession
- the JMS session used to create the messagecause
- optional exception occurred that should be sent as reply instead of a regular body- Returns:
- a newly created JMS Message instance containing the
- Throws:
jakarta.jms.JMSException
- if the message could not be created
-
appendJmsProperties
public void appendJmsProperties(jakarta.jms.Message jmsMessage, org.apache.camel.Exchange exchange, Map<String, Object> headers) throws jakarta.jms.JMSExceptionAppends the JMS headers from the CamelMessage
- Throws:
jakarta.jms.JMSException
-
appendJmsProperty
public void appendJmsProperty(jakarta.jms.Message jmsMessage, org.apache.camel.Exchange exchange, String headerName, Object headerValue) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
isStandardJMSHeader
Is the given header a standard JMS header- Parameters:
headerName
- the header name- Returns:
- true if its a standard JMS header
-
getValidJMSHeaderValue
Strategy to test if the given header is valid according to the JMS spec to be set as a property on the JMS message. This default implementation will allow:- any primitives and their counter Objects (Integer, Double etc.)
- String and any other literals, Character, CharSequence
- Boolean
- Number
- java.util.Date
- Parameters:
headerName
- the header nameheaderValue
- the header value- Returns:
- the value to use, null to ignore this header
-
createJmsMessage
protected jakarta.jms.Message createJmsMessage(Exception cause, jakarta.jms.Session session) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
createJmsMessage
protected jakarta.jms.Message createJmsMessage(org.apache.camel.Exchange exchange, Object body, Map<String, Object> headers, jakarta.jms.Session session, org.apache.camel.CamelContext context) throws jakarta.jms.JMSException- Throws:
jakarta.jms.JMSException
-
getJMSMessageTypeForBody
protected JmsMessageType getJMSMessageTypeForBody(org.apache.camel.Exchange exchange, Object body, Map<String, Object> headers, jakarta.jms.Session session, org.apache.camel.CamelContext context) Return theJmsMessageType
- Returns:
- type or null if no mapping was possible
-
createJmsMessageForType
protected jakarta.jms.Message createJmsMessageForType(org.apache.camel.Exchange exchange, Object body, jakarta.jms.Session session, org.apache.camel.CamelContext context, JmsMessageType type) throws jakarta.jms.JMSException Create theMessage
- Returns:
- jmsMessage or null if the mapping was not successfully
- Throws:
jakarta.jms.JMSException
-
populateMapMessage
protected void populateMapMessage(jakarta.jms.MapMessage message, Map<?, ?> map, org.apache.camel.CamelContext context) throws jakarta.jms.JMSExceptionPopulates aMapMessage
from aMap
instance.- Throws:
jakarta.jms.JMSException
-
createMapFromMapMessage
public Map<String,Object> createMapFromMapMessage(jakarta.jms.MapMessage message) throws jakarta.jms.JMSException Extracts aMap
from aMapMessage
- Throws:
jakarta.jms.JMSException
-
shouldOutputHeader
protected boolean shouldOutputHeader(String headerName, Object headerValue, org.apache.camel.Exchange exchange) Strategy to allow filtering of headers which are put on the JMS message Note: Currently only supports sending java identifiers as keys
-