Code Monkey home page Code Monkey logo

junglebus's Introduction

JungleBus

Transactional service bus built on top of Amazon Web Services.
Build status
Since version 3.0, the bus is built upon the JungleQueue library.

Creating the Bus

Creates a service bus that can send and recieve messages

var bus = BusBuilder.Create("Development")
	.WithObjectBuilder(new JungleQueue.StructureMap.StructureMapObjectBuilder())
	.UsingJsonSerialization()
	.PublishingMessages(typeof(TestMessage).Assembly.ExportedTypes, RegionEndpoint.USEast1)
	.SetInputQueue("Test_Queue1", RegionEndpoint.USEast1)
	.SetSqsPollWaitTime(14)
	.UsingEventHandlersFromEntryAssembly()
	.SetNumberOfPollingInstances(2)
	.CreateStartableBus();

bus.StartReceiving();
bus.CreateSendBus().Publish(new TestMessage());

#Example message handler

public class Handler2 : IHandleMessage<TestMessage>
{
	private readonly IBus _bus;
	private readonly ILog _log;
	public Handler2(IBus bus, ILog log)
	{
		_bus = bus;
		_log = log;
	}

	public void Handle(TestMessage message)
	{
		_log.Info("Starting message Handler 2");
		_bus.Publish(new TestMessage2()); // Publish event to the world
		_bus.PublishLocal(new TestMessage3())); // Publish event to self
		_log.Info("Finished message Handler 2");
	}
}

Other bus types

Send Only Bus

Creates a service bus that can only send messages

var busBuilder = BusBuilder.Create()
	.WithStructureMapObjectBuilder()
	.UsingJsonSerialization()
	.PublishingMessages(typeof(TestMessage).Assembly.ExportedTypes, RegionEndpoint.USEast1)
	.CreateSendOnlyBusFactory();
busBuilder().Publish(new TestMessage());

Receive Only Bus

Creates a service bus that can only receive messages. This bus can send messages to itself.

var bus = BusBuilder.Create()
	.WithObjectBuilder(new JungleQueue.StructureMap.StructureMapObjectBuilder())
	.UsingJsonSerialization()
	.SetInputQueue("Test_Queue1", RegionEndpoint.USEast1)
	.SetSqsPollWaitTime(14)
	.UsingEventHandlersFromEntryAssembly()
	.SetNumberOfPollingInstances(2)
	.PublishingLocalEventsOnly()
	.CreateStartableBus();
bus.StartReceiving();

junglebus's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.