com.mycompany.integration.NewMain.java Source code

Java tutorial

Introduction

Here is the source code for com.mycompany.integration.NewMain.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.integration;

import java.util.UUID;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;

/**
 *
 * @author Dominik Szalai - emptulik at gmail.com
 */
public class NewMain {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-integration.xml");

        MessageChannel channel = context.getBean("toRabbit", MessageChannel.class);

        for (int i = 0; i < 10; i++) {
            channel.send(build(UUID.randomUUID().toString()));
        }
    }

    private static Message<String> build(String string) {
        return MessageBuilder.withPayload(string).setHeader("digital-sign", true).build();
    }

}