Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better signature to send string from ROUTER to DEALER #209

Open
AntiTenzor opened this issue Sep 11, 2021 · 0 comments
Open

Better signature to send string from ROUTER to DEALER #209

AntiTenzor opened this issue Sep 11, 2021 · 0 comments

Comments

@AntiTenzor
Copy link

I heavily use ROUTER <--> DEALER communication and I see a very common pattern like this:
`
// Somewhere at the beginning of a program execution
ZSocket clrZmqRouter = new ZSocket(clrZmqContext, ZSocketType.ROUTER);

// Many minutes later IN ANOTHER THREAD
lock (clrZmqRouter)
{
string added = "serialized message with a command";
if (clrZmqRouter.SendFrameMore(new ZFrame(dealerIdentity), ZSocketFlags.More | ZSocketFlags.DontWait, out error) &&
clrZmqRouter.SendFrame(new ZFrame(added), ZSocketFlags.DontWait, out error))
{
// All good. We are happy.
}
else
{
// Log an error.
}
}
`

q1) Is it the best and CORRECT way to make NON-BLOCKING send to the dealer?

q2) Is it possible to implement special method in ZSocket for this operation?
Something like this:
bool ZSocket.SendToDealer(string dealerIdentity, string message, ZSocketFlags flags = ZSocketFlags.DontWait, out ZError error)

q3) Is it possible to make a special class ZRouter : object that will contain ZSocket as its private field ?
And provide only some special methods to simplify ROUTER <--> DEALER communication?

Also I would like to make this ZRouter class absolutely thread safe for external callers.
Is it possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant