Comments (5)
Well spotted. Fancy making a pull request?
from samples.
Okay, I will do this tonight.
from samples.
There is also a miss-match in the way replies are handled for MDPClient
vs MDPClientAsync
. In the ProcessReceiveReady
method we have in MDPClientAsync
private void OnProcessReceiveReady(object sender, NetMQSocketEventArgs e)
{
Exception exception = null;
NetMQMessage reply = null;
try
{
reply = m_client.ReceiveMultipartMessage();
if (ReferenceEquals(reply, null))
throw new ApplicationException("Unexpected behavior");
m_timer.EnableAndReset(); // reset timeout timer because a message was received
Log($"[CLIENT INFO] received the reply {reply}");
ExtractFrames(reply);
}
catch (Exception ex)
{
exception = ex;
}
finally
{
ReturnReply(reply, exception);
}
}
private void ExtractFrames(NetMQMessage reply)
{
if (reply.FrameCount < 4)
throw new ApplicationException("[CLIENT ERROR] received a malformed reply");
var emptyFrame = reply.Pop();
if (emptyFrame != NetMQFrame.Empty)
{
throw new ApplicationException($"[CLIENT ERROR] received a malformed reply expected empty frame instead of: { emptyFrame } ");
}
var header = reply.Pop(); // [MDPHeader] <- [service name][reply] OR ['mmi.service'][return code]
if (header.ConvertToString() != m_mdpClient)
throw new ApplicationException($"[CLIENT INFO] MDP Version mismatch: {header}");
var service = reply.Pop(); // [service name or 'mmi.service'] <- [reply] OR [return code]
if (service.ConvertToString() != m_serviceName)
throw new ApplicationException($"[CLIENT INFO] answered by wrong service: {service.ConvertToString()}");
}
Then in MDPClient
private void ProcessReceiveReady (object sender, NetMQSocketEventArgs e)
{
// a message is available within the timeout period
var reply = m_client.ReceiveMultipartMessage ();
Log ($"\n[CLIENT INFO] received the reply {reply}\n");
// in production code malformed messages should be handled smarter
if (reply.FrameCount < 3)
throw new ApplicationException ("[CLIENT ERROR] received a malformed reply");
var header = reply.Pop (); // [MDPHeader] <- [service name][reply] OR ['mmi.service'][return code]
if (header.ConvertToString () != m_mdpClient)
throw new ApplicationException ($"[CLIENT INFO] MDP Version mismatch: {header}");
var service = reply.Pop (); // [service name or 'mmi.service'] <- [reply] OR [return code]
if (service.ConvertToString () != m_serviceName)
throw new ApplicationException ($"[CLIENT INFO] answered by wrong service: {service.ConvertToString()}");
// now set the value for the reply of the send method!
m_reply = reply; // [reply] OR [return code]
}
These should be the same, or have I missed something?
from samples.
I'm not sure, less familiar with this code sample. Anyway, if you think something is wrong, fix it and send a PR. If you are wrong, someday someone else will send a PR to fix that.
from samples.
Okay, fair enough. I am undergoing a process of creating a new type of transport mechanism based on Majordomo, if I find any further anomalies I will send a PR.
from samples.
Related Issues (13)
- Assembly NetMQ, Version=3.3.2.2 Multiple Publishers Beacon Not working
- InterBrokerRouter needed to update. found bug in line 207
- In Majordomo Pattern , Implementation of New Async method for post processing after message received
- Bug inside PPP Queue component: Available Worker Management HOT 1
- message cutting HOT 15
- Is it correct that services are always added to the list even if they have the same name?
- NetMQ doesn't appear to communicate with pyzmq? HOT 2
- Samples: InterBrokerRouter Error
- PubSub sample (WeatherUpdate) doesn't use the recommended multi-part technique
- Majordomo: Timeout, Heartbeat, Disconnects HOT 7
- Broker disconnected after certain interval after getting following error
- Question: Paranoid Pirate Pattern auto re-connect for workers and clients on queue restart HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from samples.