Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Agent framework designed for testing ZeroMQ Applications
Ruby
Branch: master
Pull request Compare This branch is 14 commits behind connamara:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
config
features
lib
spec
.document
.gitignore
.rspec
.travis.yml
CONTRIBUTION_GUIDELINES.md
Gemfile
Gemfile.lock
LICENSE.txt
README.md
Rakefile
VERSION
agent_zeromq.gemspec

README.md

agent_zeromq

Agent framework designed for testing ZeroMQ Applications

Usage

Agent Types

The agent types correspond to underlying ZMQ Socket type under test

ZMQ_SUB

  • Connects or Binds to local address
  • Includes message caching for inspection

ZMQ_PUB

  • Connects or Binds to local address
  • Publishes

ZMQ_REQ

  • Connects or Binds to local address
  • Publishes request, returns response

ZMQ_REP

  • Connects or Binds to local address
  • Listens for request, sends response

Configuration

Inside of your project, declare your agents inside of config/zmq_agents.rb like this:

require 'agent_zeromq'

AgentZeroMQ.define_ZMQ_SUB :my_sub_agent do |a|
  a.socket_opts << {ZMQ::SUBSCRIBE=>'com.connamara.BODPosition'}
  a.end_point_type=:bind
  a.end_point='tcp://*:5556'
end

AgentZeroMQ.define_ZMQ_PUB :my_pub_agent do |a|
  a.end_point_type=:connect
  a.end_point='tcp://127.0.0.1:5558'
end

AgentZeroMQ.define_ZMQ_REQ :my_req_agent do |a|
  a.end_point_type=:connect
  a.end_point='tcp://127.0.0.1:5552'
end

AgentZeroMQ.define_ZMQ_REP :my_rep_agent do |a|
  a.reply = Proc.new {|msg| "ok"}
  a.end_point_type=:bind
  a.end_point='tcp://*:5552'
end

Starting, Stopping and Resetting

require 'agent_zeromq'
AgentZeroMQ.start
at_exit { AgentZeroMQ.stop }

You may want to reset the agent states between tests without stopping and starting. This may be done with AgentZeroMQ.reset

Getting your agent

Grab the agent by the name given in the config file

my_agent = AgentZeroMQ.agents_hash[:my_sub_agent]  

Agent Interfaces

ZMQ_SUB

This agent provides a message cache

all_messages_received = my_sub_agent.messages_received

# returns and removes the last message received from the cache
last_message_received = my_sub_agent.pop

On reset, the sub agent cache is cleared

ZMQ_PUB

The publish method takes a single message of one or more parts

my_pub_agent.publish "single part message"
my_pub_agent.publish ["part 1", "part 2"]

ZMQ_REQ

The publish method takes a single message of one or more parts. The agent blocks until a response is received and returned as an array of message parts

response = my_req_agent.publish "single part message"
response = my_pub_agent.publish ["part 1", "part 2"]

ZMQ_REP

Like the ZMQ_SUB agent, ZMQ_REP provides a message cache

all_messages_received = my_rep_agent.messages_received

# returns and removes the last message received from the cache
last_message_received = my_rep_agent.pop

When receiving requests, the agent will reply with the output of the reply Proc. The return value of this proc may be in the form of a multi-part message.

Cucumber

There is some support for cucumber. See features for example usage.

More

Check out specs and features to see all the ways you can use agent_zeromq.

Install

gem install agent_zeromq

or add the following to Gemfile:

gem 'agent_zeromq'

and run bundle install from your shell.

More Information

Contributing

Please see the contribution guidelines.

Credits

Contributers:

  • Chris Busbey
  • Brad Haan

Connamara Systems

agent_zeromq is maintained and funded by Connamara Systems, llc.

The names and logos for Connamara Systems are trademarks of Connamara Systems, llc.

Licensing

agent_zeromq is Copyright © 2013 Connamara Systems, llc.

This software is available under the GPL and a commercial license. Please see the LICENSE file for the terms specified by the GPL license. The commercial license offers more flexible licensing terms compared to the GPL, and includes support services. Contact us for more information on the Connamara commercial license, what it enables, and how you can start developing with it.

Something went wrong with that request. Please try again.