Skip to content

Allow byte[] class to be mapped from DefaultJmsHeaderMapper #3788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RogerLapin opened this issue May 5, 2022 · 1 comment · Fixed by #3789
Closed

Allow byte[] class to be mapped from DefaultJmsHeaderMapper #3788

RogerLapin opened this issue May 5, 2022 · 1 comment · Fixed by #3789

Comments

@RogerLapin
Copy link

Expected Behavior

When a message (produced by IBM MQ) comes through (eg) a message-driven-channel adapter (or any adapter that will use DefaultJmsHeaderMapper), it will map any (non-JMS) fields whose type belongs to SUPPORTED_PROPERTY_TYPES.
It include IBM Byte arrays (MQBYTE24 and LMQBYTE32 )

Current Behavior

When a header of the incoming message is of type byte[], it will be ignored because it is not part of SUPPORTED_PROPERTY_TYPES.

Context

This is a problem when you need to transmit some MQBYTExx headers that must remain untouched and send as MQMD headers (and not JMS). For example, JMS messageId will not be retained by a target MQ Series broker, and will be replaced by a new generated one. This makes the pattern REQUEST/REPLY (based on msgId / CorrelId) fail.

Our current workaround is to take over the mapper through a customized one.

Exemple of the workaround for IBM MQMD MsgID

public class MqCompatibleJmsHeaderMapper extends DefaultJmsHeaderMapper {
...
  public void fromHeaders(MessageHeaders headers, Message jmsMessage) {
	Object messageId = headers.get(WMQConstants.JMS_IBM_MQMD_MSGID);
	if(messageId !=null) {
		if (messageId instanceof byte[]) {
			jmsMessage.setObjectProperty(WMQConstants.JMS_IBM_MQMD_MSGID, messageId);
		}else  {
		 ...
		}
	}
	super.fromHeaders(headers, jmsMessage);
  }

...
}
@RogerLapin RogerLapin added status: waiting-for-triage The issue need to be evaluated and its future decided type: enhancement labels May 5, 2022
@artembilan artembilan added this to the 6.0 M3 milestone May 5, 2022
@artembilan artembilan added in: jms backport 5.5.x and removed status: waiting-for-triage The issue need to be evaluated and its future decided labels May 5, 2022
artembilan added a commit to artembilan/spring-integration that referenced this issue May 5, 2022
Fixes spring-projects#3788

Some JMS vendors carry some important information in their JMS messages.
That information can be stored in the specific properties as `byte[]`.

* Add `byte[]` as a supported property type into a `DefaultJmsHeaderMapper`
* Verify `byte[]` property mapping and propagation via embedded ActiveMQ
broker.

**Cherry-pick to `5.5.x`**
garyrussell pushed a commit that referenced this issue May 5, 2022
Fixes #3788

Some JMS vendors carry some important information in their JMS messages.
That information can be stored in the specific properties as `byte[]`.

* Add `byte[]` as a supported property type into a `DefaultJmsHeaderMapper`
* Verify `byte[]` property mapping and propagation via embedded ActiveMQ
broker.

**Cherry-pick to `5.5.x`**
@artembilan
Copy link
Member

We decided to not back-port to the previous version since it turned out an ActiveMQ does not support a byte[] unlike Artemis we use in the current 6.0 to support Jakarta EE.
At least we know that workaround is simple if byte[] mapping is supported and required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants