logo
down
shadow

How to send XML file to ActiveMQ?


How to send XML file to ActiveMQ?

By : user3044362
Date : December 01 2020, 04:45 PM
should help you out In JMS (and messaging in general) you send messages not files. You can turn your file into a message by reading the data from the file and putting into a JMS text or bytes message. The simplest solution would be something like this:
code :
public class Main {
    private static String url = ActiveMQConnection.DEFAULT_BROKER_URL;
    private static String subject = "TestQueue";

    public static void main(String[] args) throws JMSException {
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
        Connection connection = connectionFactory.createConnection();
        connection.start();

        Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createQueue(subject);
        MessageProducer producer = session.createProducer(destination); 
        String xml = readXmlFromFile();
        TextMessage message = session.createTextMessage(xml);
        producer.send(message);
        connection.close();
    }

    private static String readXmlFromFile() {
        // read XML from file
    }
}


Share : facebook icon twitter icon
ActiveMQ/Camel send file for further processing

ActiveMQ/Camel send file for further processing


By : Tom G
Date : March 29 2020, 07:55 AM
will help you Camel's content based router is what you are looking for. It allows you to setup routing rules based on the message body/headers/properties...
Here is a basic example that reads from an inbound queue and simply delegates to other queues based on headers...
code :
   from("activemq:queue:inboundQueue")
        .choice()
            .when(header("foo").isEqualTo("bar"))
                .to("activemq:queue:barQueue")
            .when(header("foo").isEqualTo("cheese"))
                .to("activemq:queue:cheeseQueue")
            .otherwise()
                .to("activemq:queue:generalQueue");
yum install activemq activemq-client - no package activemq available

yum install activemq activemq-client - no package activemq available


By : nikos mitsis
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , For a simple installation following the tutorial you have to enable different repos for yum, this can be done by
code :
subscription-manager repos --enable=*repoid*
subscription-manager repos --list
Unable to send local file to activeMQ

Unable to send local file to activeMQ


By : hemadri_ kanaparthi
Date : March 29 2020, 07:55 AM
hop of those help? Yes when using blob you need to use an out of band transport, see more details at: http://activemq.apache.org/blob-messages.html
Then you need to setup that chosen such as ftp,http etc and add the dependencies to the client classpath.
How to send a file to the ActiveMQ Queue?

How to send a file to the ActiveMQ Queue?


By : CHINNU B.R
Date : March 29 2020, 07:55 AM
To fix this issue @Mary Zheng provided an excellent example, how it may be done:
ActiveMQ File Transfer Example
code :
private void sendFileAsBytesMessage(File file) throws JMSException, IOException {
    BytesMessage bytesMessage = session.createBytesMessage();
    bytesMessage.setStringProperty("fileName", file.getName());
    bytesMessage.writeBytes(fileManager.readfileAsBytes(file));

    msgProducer.send(bytesMessage);
}
ConnectionFactory connFactory = 
    new ActiveMQConnectionFactory(username, password, activeMqBrokerUri);
Connection connection = connFactory.createConnection();
ActiveMQSession session = 
    (ActiveMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
public class FileAsByteArrayManager {

    public byte[] readfileAsBytes(File file) throws IOException {    
        try (RandomAccessFile accessFile = new RandomAccessFile(file, "r")) {
            byte[] bytes = new byte[(int) accessFile.length()];
            accessFile.readFully(bytes);
            return bytes;
        }
    }

    public void writeFile(byte[] bytes, String fileName) throws IOException {
        File file = new File(fileName);
        try (RandomAccessFile accessFile = new RandomAccessFile(file, "rw")) {
            accessFile.write(bytes);
        }
    }
}
ActiveMQ send and receive folder of XML file

ActiveMQ send and receive folder of XML file


By : Afia Khan
Date : March 29 2020, 07:55 AM
I wish did fix the issue. ActiveMQ is not a storage facility, it is a message-passing facility.
That being said you should look at Camel, Mule or Spring Integration, all of which can use ActiveMQ for messaging. They all have support for polling folders for files to send as messages and depositing messages into folders.
Related Posts Related Posts :
  • Android Broadcastreceiver for other apps install/delete not working
  • Android Studio onClick not working in BindViewHolder
  • How to use Spring Converter for some controllers only?
  • How verify that 3 numbers in sequence are equals?
  • When using .compareTo to compare dates, why doesn't it take Months into account?
  • Does the perfomance of "filter then map" and "map then filter" differ in a Stream?
  • How can I set the initial Delay after pressing the start Button to a specific time (HH:mm:ss) format
  • How to switch between Android devices during the tests
  • How to configure java.util.logging via properties to use standard output?
  • How to iterate through array in order
  • Is there better way of iteration to find the evenly divisible number?
  • How to split a string to non empty words if it might include a separator like tab on first place
  • Supplier<Sequence<String>> cannot be iterated more than once
  • Why there is only one thread can actually started in @PostConstruct method?
  • Manage CompletionStage inside of Netty handler
  • Url Problem while Developing on Localhost and deploy on Remote Virtual Server
  • How to identify the missing type id in Jackson error?
  • android data binding error: cannot find symbol
  • Spring Boot application with a jar dependency does not run after maven build
  • Spring Data JPA query , filter ? search engine ? JPQL?
  • Why LiveData returns null in ViewModel?
  • what this line of code mean....new URLClassLoader(new URL[0],getClass().getClassLoader());
  • Why do need to use new Random() instead of just Random Randomnum?
  • I want to access zk components from the java file
  • How do I cast FieldValue.serverTimestamp() to Kotlin/Java Date Class
  • Insertion Sort Double Array with User Input - JAVA
  • Creating 2 dimesional array with user input and find sum of specific columns
  • can not get Advertising ID Provider in android
  • Convert list of Objects to map of properties
  • How to represent an undirected weighted graph in java
  • Return values as array from collection
  • ByteBuddy generic method return cast to concrete type
  • ImageView hides the round corners of the parent
  • Is there a way to find setter method by its getter method or vice versa in a class?
  • Get aggregated list of properties from list of Objects(Java 8)
  • Unable to find a document in Mongodb where exact date match in java
  • UsernamePasswordAuthenticationFilter skips success handler
  • Use Java filter on stream with in a stream filter
  • Default Login not successful in spring boot 2.1.7
  • Adding key value pairs from a file to a Hashmap
  • Rub regex: matching a char except when after by another char
  • Convert Base64 String to String Array
  • Escape Unicode Character 'POPCORN' to HTML Entity
  • An empty JSON field which is a boolean/nullable field in Java model, is getting converted as null
  • Mongo java driver cannot find public constructor for interface
  • How to unit test writing a file to AWS Lambda output stream?
  • How to make a GitHub GraphQL API Call from Java
  • What's the difference between @ComponentScan and @Bean in a context configuration?
  • Expected class or package adding a view using a class
  • can be delete of a element in a static array be O(1)?
  • Instance variable heap or stack ? ( with specific example)
  • Assert progress of ProgressBar in Espresso test
  • How to detect if gson.fromjson() has excess elements
  • I cant generate the proper code to select the a specific filter on a BI dashboard I am working on
  • How to Inject Dependencies into a Servlet Filter with Spring Boot Filter Registration Bean?
  • Thrift types as a Generic
  • Effective algorithm to random 4 unique integers less than a big max such as 100_000
  • Combining or and negation in Java regex?
  • Unable to instantiate default tuplizer Exception
  • Multi-tenant migration to work with quarkus
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org