SolaceProducts / solace-spring-cloud

An umbrella project containing all Solace projects for Spring Cloud
Apache License 2.0
20 stars 14 forks source link

[Bug]: FlowId not matching with incoming message and silent existing. #299

Closed hirenhcm closed 2 months ago

hirenhcm commented 2 months ago

Bug Description

Facing an issue with connecting to my OnPrem Solace server. The same issue is not seen on my local Solace using docker.

I have created a Simple Spring Boot Application that produces a message on a topic and consumes the same. I am using the below version to achieve this.

JDK 17
spring-boot-starter-parent: 3.2.5
spring-cloud-starter-stream-solace: 5.1.0 also tried 5.0.0
spring-cloud-stream: 4.1.0 also tried 4.0.0

When enabling debug logs I see that the messages are getting read by the consumer that are pending on the queue. But are getting skipped or silently ignored as per the logs.

Expected Behavior

FlowId generated at the boot of the application should be same when a message reaches the consumer.

Steps to Reproduce

When Spring Boot starts up it creates the below logs and registers the below flowId.

20:30:47.077 [Context_2_ReactorThread] DEBUG c.s.jcsmp.impl.RequestResponseTask , - RequestResponseTask ([BRT resource=APPS.INTERNAL.COUCHBASE.V1 existingFH=null flowType=CONSUMER_REDELIVERY_FLOW counter=1]) cancelTimer 
20:30:47.077 [Context_2_ReactorThread] DEBUG c.s.j.impl.timers.SubAckTimedTask , - Creating SubAckTimedTask.
20:30:47.077 [Context_2_ReactorThread] DEBUG c.s.jcsmp.impl.flow.FlowHandleImpl , - Flow 0: Clear AD timer
20:30:47.077 [Context_2_ReactorThread] DEBUG c.s.jcsmp.impl.flow.BindRequestTask , - Client-1: Got OK bindresponse, flowName=null, flowId=3208652207, QueueAccessType=NON_EXCLUSIVE, explicitlyActive=false
20:30:47.077 [Context_2_ReactorThread] DEBUG c.s.j.impl.flow.SubFlowManagerImpl , - Client-1: regActiveFlow id=3208652207
20:30:47.078 [Context_2_ReactorThread] DEBUG c.s.j.impl.flow.SubFlowManagerImpl , - Client-1: addManagedFlow Flowid=3208652207
20:30:47.078 [restartedMain] DEBUG c.s.jcsmp.impl.flow.FlowHandleImpl , - Client-1:SubFlow-3208652207: Flow 3208652207: getWindowSize()=255

When a message is already in the queue or a new message reaches the queue we see the below logs getting printed.

12:47:07.995 [Context_2_ReactorThread] DEBUG c.s.jcsmp.protocol.impl.SmfUhUtil , - Ignored one or more unknown parameters in SMF header.
12:47:07.995 [Context_2_ReactorThread] DEBUG c.s.j.impl.flow.SubFlowManagerImpl , - Client-1: Demux pub msg:com.solacesystems.jcsmp.impl.JCSMPGenericXMLMessage[messageId=15,ackMessageId=25429524241,prevId=14,CID_count=0,userData=,type=PERSISTENT,priority=4,redelivered=false,timeToLive=0,expiration=0,dmqEligible=true,topicSeqNum=null,metadataLen=0,contentLen=0,attLen=33,sendAttemptedOnce=false,ackImmediately=false,safeToRelease=false,retransmitting=false,sendCount=0@550307b0]
12:47:07.995 [Context_2_ReactorThread] DEBUG c.s.j.impl.flow.SubFlowManagerImpl , - Client-1: Received incoming message with no active flow found for flowId=-1086231418, ignoring.

Looking at the flowId it is a negative ID and does not match the flow ID that is generated at the start when Spring Boot starts up.

I have also identified the issue why the flowId does not match when a message reaches the consumer. This issue lies under sol-jcsmp-10.22.0.jar(This is a jar is been decompiled and debugged.)

Here we see as issue in com.solacesystems.jcsmp.protocol.smf.impl.SMFHeaderDecoder.class. Here the flowId generated is a Long but getting converted to a int which is a out of range if the number is generated is large i.e Client-1: regActiveFlow id=3208652207

h.setPm_ad_flowid((int)TlvParameterParser.getSmfAssuredFlowId(parambuf, off));

Additionally, the setPm_ad_flowid is also an int in the class com.solacesystems.jcsmp.protocol.smf.SMFHeaderBean.

Looking at this it clearly shows as a bug.

However, I do not have a workaround for this and am exploring options to downgrade but this will also require me to downgrade my spring version.

Request the team to fix this or give me an alternate workaround to resolve this.

Solace Broker version

10.4.1.59

Solace API

No response

Solace API version

5.0.0 and 5.1.0

mackenza commented 2 months ago

Hello, this is likely not a bug on the Spring starter and is more likely something environmental (it works on your local but not on prem company broker) or, perhaps, a problem with JCSMP. I am going to close this issue here and recommend you take it up in 1 of 2 ways:

Someone should be able to help you there.

Andrew MacKenzie Product Manager, Solace

hirenhcm commented 2 months ago

It is clearly an issue within sol-jcsmp.jar. Can you please guide me where I can log a bug for this jar. It clearly says it a solace jar but could not find the author.

mackenza commented 2 months ago

sol-jcsmp.jar is our legacy Java API and is a supported project, but not open-source. I see you have posted in the Community and someone will help you there.