Using RemoteChannels in a Publisher/Subscriber Model


Hello all!

I’m interested in leveraging Julia’s built-in RemoteChannels to replicate some of the functionality that ROS ( provides. Unfortunately I’m running into some issues with calling put! on a RemoteChannel. Calling put! on a channel will block if the Channel is full, but what I would like is for put! to replace the oldest item in the Channel’s buffer. In this way, put! will never block the publisher, and the subscriber will always have access to the latest data.

Anyone have suggestions on an elegant way to make this happen? Looking at the source code it looks like one ugly but fairly easy way to make this happen is first check if the Channel is full before calling put!, and if so manually remove the oldest item in the Channel’s buffer.



It seems like you’re trying to work against the intended use of RemoteChannel here in terms of delivery guarantees and it’s probably the wrong API for what you’re doing.

If you’re looking for pub sub, perhaps something like ZMQ.jl would fit your use case better? Having a quick look at that, it seems to be relatively low level so you’d presumably have to do a bit of plumbing for serialization and deserialization.


I am also trying to do this. I use RobotOS.jl to communicate with ROS (48 nodes providing simultaneous measurements) but this soaks up a whole thread. Elsewhere I use LibPQ for database interaction, RigidBodyDynamics for robot control, and much of my own heavy-weight processing none of which has anything to do with ROS. The matrices aren’t huge but I want to make use of Julia’s distributed programming and shared arrays since everything must be as close to real-time as poss.

It seems “cleaner” to do non-ROS stuff outside of ROS from the separation of concerns point of view. It would also be faster if I could specify a particular core for my Julia-ROS API and all the others for the other work. But ROS already uses a pub/sub message queue and in my head I can’t justify using ZMQ pub/sub to talk to ROS’s own pub/sub! Yet aside from putting all my code in a catkin container, which precludes running it on another server than ROS, I can’t think of anything else to do.

So I have two running instances of Julia, each with myid() = 1. I therefore need Julia to Julia comms that allows shared memory.

I hope this IS the same question as @colinxs asked. If not I apologise and I will shoot myself quietly.