Working around pre-fetch in Tibco EMS and .NET API

2019-07-27 11:21发布

问题:

All in context of Tibco EMS 5.* and .NET API

I've to work along existing model of message processing, in which in a loop:

  • connection is created / open
  • session is created / open
  • message consumer is created
  • receive method is called

if message != null then we consume it and either commit or rollback the transaction (on underlying session). System pulls every x sec in that model.

I've created a connection factory that assures that only new sessions are created (if the previous session is still in use). In that way system works on the same connection.

However, I've run into issue with pre-fetch as each Receive call (by .NET interface) returns one message and puts several (pre-fetch-1) to local queue. So I should reuse the same session next time really in order to read messages that are already pulled. I've put in wrappers to reuse the session & message consumer as long as there is something there (Receive won't return null). This approach kind of works, but it seems that I might have get null on Receive, even though there is still something fetched locally. It also seems that as long as I’m on the same connection fetched messages will be marked as delivered (even if session is explicitly closed).

Would someone have any idea how to either open connection / session with pre-fetch = 1? Or there is better solution?

Thanks in advance,

回答1:

Workaround: turn-off prefetching on the queue level.