Lets say there are two receiver session from same application to a SMPP over different TCP ports.
Message is sent to application and reply is (i.e deliver_sm_resp) is coming to SMPP via the other session
Is this possible or reply should be come over the same SMPP session?
No, the deliver_sm_resp should be sent back using the same session as the deliver_sm was received on.
The response is linked with the request by a sequence number that is incremented with each request on the session so the it only makes sense within the same session.
Related
I have a distributed system application that uses JBoss as an application server. I have a client application that serves as a simulation engine. When client is up, it sends an registration message(JMS message) to Server, then some field is set in the database. When Server is up, it sends a message ( a topic) to all clients to check that they are alive. If clients are alive, they can read message and send a response to server (queue) that it is alive.
If user close client normally, client send a message to server that I will unregister. Then server unregisters it. This is done in database side.
If user close client abnormally(kill) , then client can not send a message to server for unregistration. Then server does not know this client is not alive anymore. This causes inconsistency in my application. So I need a way to understand that client subscribed a topic is not subscribed anymore.
Server sends a message to topic to check that clients are alive.
#Schedule(hour = "*", minute = "*", second = "30", persistent = false)
public void sendNodeStatusRequest() {
Message msg = MessageFactory.createStatusRequestMessage();
publishNodeMessage(msg);
}
After a time, Server show following logs. Could I catch this warning from Java?
07:17:00,698 WARN [org.hornetq.core.protocol.core.impl.RemotingConnectionImpl] Connection failure
has been detected: Did not receive ping from /127.0.0.1:61888. It is likely
the client has exited or crashed without closing its connection, or the
network between the server and client has failed. The connection will now be closed. [code=3]
07:17:00,698 WARN [org.hornetq.core.server.impl.ServerSessionImpl] Client
connection failed, clearing up resources for session 4e4e9dc6-153e-11e7-
80fa-742b62812c29
To me the whole point of messaging system is decoupled communication. The sender (server in your case) send its stuff to the topic without actually knowing who will get the message. The clients come and go, and they should be able to read the message whenever it (still) resides in the topic.
Now from your question I understand that the server keeps track of all the connected clients by means of receiving the message back to the dedicated queue.
So I'm asking myself - maybe its something wrong with the design here.
Let me propose slightly different way of implementation.
The server should not be aware of any client, at most (because your system seems to work this way) it should know that client A, B and C are alive now only because these clients passed to the server this knowledge.
Why just don't make clients sending the "keep-alive" message every, say 1 minute (or less, depending on your needs) to the server queue without prior message from the server.
The message can include some client identifier and probably time if its not added by the infrastructure or something)
So the server will just get this message and it will keep track in memory the list of available clients along with the last time they've sent something.
So if some client disconnects "gracefully" - it can send a special message to the server like "I'm client A and consider me disconnected". Otherwise (abnormal termination/network outage/whatever) - it just won't send anything, the server will have a special process that will check whether there are stale clients on the list and if it finds them - it knows that something went wrong.
If you still want to stick with JMS way of doing, then you can try to send the message synchronously, meaning the producer will wait until it hears from the consumer. More information here : http://docs.oracle.com/javaee/6/tutorial/doc/bncfa.html
I'm using channel-adapters (not gateways) to send data with MessagingTemplate's sendAndReceive from spring integration server to a connected nonspring client (or just telnet).
After receiving the data in the client, somewhen I want to reply data to the server and resolve that sendAndReceive-Waiting. I still want to be able to send other data to the server.
How will sendAndReceive detect a response? Right now I can send whatever I want to the server, it will assume it as a new incoming message.
Is there a predefined way, like prefixing a messageid or do I have to implement it manually by interpreting the incoming messages and somehow "resolve" the sendAndReceive-blocker?
MessagingTemplate.sendAndReceive is based on the TemporaryReplyChannel which is placed to the MessageHeaders and afterward some AbstractReplyProducingMessageHandler just uses that header to send reply back.
Yes, the sending Thread is blocked to wait for the reply throughout that TemporaryReplyChannel.
Hope that can help you a bit.
All other your comment regarding TCP/IP isn't clear for me yet...
I am developing a chat server through netty websocket. Our client side is mostly browser based.
What's happening is, when I refresh the browser it closes the websocket connection and losses everything and creates a new socket when browser is loaded again.
Is there any mechanism which shall reconnect with my previous websocket session at server side.
I am planning to cache all user session and if received any connection close event from client side then without deleting user session information waiting more 30-60s,in between if server receive new connection request from same client(detecting through cookies id) then replacing by new session information.
My problem is if I do not remove session when server receive connection close event , other read/write operation through this session's channel creating problem.
What I can understand from following is
My problem is if I do not remove session when server receive connection close event , other read/write operation through this session's channel creating problem.
Your chat logic is tightly coupled with the channel/channel handler object.
If you can move the chat logic to a separate class which I call "Session" and have onEventXXX callbacks in that class and have chat logic on top of it (separate chain of classes may be), when there is a write operation, write the message using session.write(...). The "Session" have to delegate it to the underlying channel.
When the underlying channel is closed, you can keep the "Session" object for while and reattach with it's new channel.
To do this you might need to create a separate Netty handler called "SessionHandler" and process channel events/session creation.
I have a problem like two clients should be accessing my web application.
My first question is how can i know that two clients exist.
If two clients exist i should have a communication as mentioned below.
Client1 should write
once client1 writes then client2 should read it and will respond
once client2 writes then client1 should read it and will respond
in this pattern my communication should happen.
Any help will be appreciated...Thanks in advance
Create an HttpSessionListener which will maintain a set of active sessions. When a servlet gets a request from client1 save request body in a client1 session attribute then look for client2 session in active session set, if found take body (previous client2 request) from there and send it as a response to client1.
i think you are looking for jsr 356.
I am trying to create a client socket connection, when a new request is created a connection is established & data transfer takes place. Is there any way that once the Connection is created it will be open for all time ? If yes then how can create it & also how can I identify what request is sent & got the response for the same request?
Looking forward for your response.
You can create a connection for all time, by not closing it. However the trick is detecting when a connection has failed. e.g. the client/server has restarted.
If you want to match requests to responses you can use a request id, but a much simpler approach is to only send one request at a time per socket, that way the response you get is for the request you just sent. You can use more than one socket in a thread if this is required.