twitter-archive / cloudhopper-smpp

Efficient, scalable, and flexible Java implementation of the Short Messaging Peer to Peer Protocol (SMPP)
Other
382 stars 356 forks source link

How to connect async submit_sm and its submit_sm_resp #76

Closed abin-mathew closed 9 years ago

abin-mathew commented 9 years ago

I am using cloudhopper to send async message submissions. Since I have to log every messages sent through the system, I make a data store entry for every message before it is submitted. Then I do an async submit with the row_id from data store as an optional parameter. Now my session handler captures smpp_async_resp, reads the row_id from optional parameter and updates the row with the message id. So basically i am passing row_id to the smpp server so that when the server responds, the response pdu will have the row id in it. Is there a better way to do this? There has to be some other way to connect the async submit with the submit response. What am I missing? Please help

jjlauer commented 9 years ago

Well, while you're method works -- each SMPP pdu is assigned a unique id from a sequence. The response back on a session contains the same numeric identifier. The id is only valid per-session though. So to match up responses to requests, I'd suggest you use the numeric id of the packet. sendRequestPDU will assign the value for you unless it's been pre-assigned (which i would not recommend doing in your own code).

Basically, you send the PDU, then store the id assigned to it in your db (and the update to your db needs to be done quickly in case a response comes in fast). When the response comes in, you look it up via that id. And you need to do this per-session.

What many people do is simply keep the sequence id <-> your id in-memory.

You're pretty lucky your upstream SMSC allows you to include an optional parameter. Most don't. If you only plan on supporting them then the way you're doing it may be entirely ok. Just know that most SMSCs don't support it and you'll end up doing what i suggested at a later time.