Package org.axonframework.commandhandling.gateway

Examples of org.axonframework.commandhandling.gateway.CommandGateway


    public static void main(String[] args) {
        // Load the spring beans from the xml configuration file.
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("basic-config.xml");

        // Obtain the gateway from the context to send commands.
        CommandGateway commandGateway = applicationContext.getBean("commandGateway", CommandGateway.class);

        // and let's send some Commands on the CommandBus.
        CommandGenerator.sendCommands(commandGateway);
    }
View Full Code Here


        // we use the repository to register the command handler
        AggregateAnnotationCommandHandler.subscribe(ToDoItem.class, repository, commandBus);

        // the CommandGateway provides a friendlier API to send commands
        CommandGateway commandGateway = new DefaultCommandGateway(commandBus);

        // and let's send some Commands on the CommandBus.
        CommandGenerator.sendCommands(commandGateway);

        // we need to stop the disruptor command bus, to make sure we release all resources
View Full Code Here

        // Sagas often need to send commands, so let's create a Command Bus
        CommandBus commandBus = new SimpleCommandBus();

        // a CommandGateway has a much nicer API
        CommandGateway commandGateway = new DefaultCommandGateway(commandBus);

        // let's register a Command Handler that writes to System Out so we can see what happens
        commandBus.subscribe(MarkToDoItemOverdueCommand.class.getName(),
                new CommandHandler<MarkToDoItemOverdueCommand>() {
                    @Override
View Full Code Here

    public static void main(String[] args) {
        // let's start with the Command Bus
        CommandBus commandBus = new SimpleCommandBus();

        // the CommandGateway provides a friendlier API to send commands
        CommandGateway commandGateway = new DefaultCommandGateway(commandBus);

        // we'll store Events on the FileSystem, in the "events" folder
        EventStore eventStore = new FileSystemEventStore(new SimpleEventFileResolver(new File("./events")));

        // a Simple Event Bus will do
View Full Code Here

        // Load the amount of times to send the commands from the command line or use default 1
        Integer numberOfCommandLoops = determineNumberOfCommandLoops();

        // and let's send some Commands on the CommandBus.
        CommandGateway gateway = new DefaultCommandGateway(commandBus);
        for (int i = 0; i < numberOfCommandLoops; i++) {
            CommandGenerator.sendCommands(gateway);
        }
    }
View Full Code Here

        // Load the spring beans from the xml configuration file.
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("distributed-config.xml");

        // Obtain the gateway from the context to send commands.
        CommandGateway commandGateway = applicationContext.getBean("commandGateway", CommandGateway.class);

        // Load the amount of times to send the commands from the command line or use default 1
        Integer numberOfCommandLoops = RunDistributedCommandBus.determineNumberOfCommandLoops();

        for (int i = 0; i < numberOfCommandLoops; i++) {
View Full Code Here

    public static void main(String[] args) throws InterruptedException {
        // Load the spring beans from the xml configuration file.
        ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("disruptor-config.xml");

        // Obtain the gateway from the context to send commands.
        CommandGateway commandGateway = applicationContext.getBean("commandGateway", CommandGateway.class);

        // and let's send some Commands on the CommandBus.
        CommandGenerator.sendCommands(commandGateway);

        // close the application context
View Full Code Here

    public static void main(String[] args) {
        // let's start with the Command Bus
        CommandBus commandBus = new SimpleCommandBus();

        // the CommandGateway provides a friendlier API to send commands
        CommandGateway commandGateway = new DefaultCommandGateway(commandBus);

        // we'll store Events on the FileSystem, in the "events" folder
        EventStore eventStore = new FileSystemEventStore(new SimpleEventFileResolver(new File("./events")));

        // a Simple Event Bus will do
View Full Code Here

        assertTrue("Failed to connect", connector1.awaitJoined(5, TimeUnit.SECONDS));
        assertTrue("Failed to connect", connector2.awaitJoined(5, TimeUnit.SECONDS));

        DistributedCommandBus bus1 = new DistributedCommandBus(connector1, new AnnotationRoutingStrategy(
                UnresolvedRoutingKeyPolicy.RANDOM_KEY));
        CommandGateway gateway1 = new DefaultCommandGateway(bus1);

        doThrow(new RuntimeException("Mock")).when(serializer).deserialize(argThat(new TypeSafeMatcher<SerializedObject<byte[]>>() {
            @Override
            protected boolean matchesSafely(SerializedObject<byte[]> item) {
                return Arrays.equals("<string>Try this!</string>".getBytes(Charset.forName("UTF-8")), item.getData());
            }

            @Override
            public void describeTo(Description description) {
            }
        }));

        try {
            gateway1.sendAndWait("Try this!");
            fail("Expected exception");
        } catch (RuntimeException e) {
            assertEquals("Mock", e.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of org.axonframework.commandhandling.gateway.CommandGateway

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.