This feature is very useful in many situations. Today, Virtual destination solved one of my problems. Here is the use case. In one of our currently application, the message processing route looks like as the following:
We need the new case looks like the following:
The new requirement asks us to put all messages which have the property of MessageType = 'SFDC Reject'. Basically, we want to know what has been rejected by SFDC system. We may retry it or send email to the interesting parties. For the moment, we don't know what exactly the process.
Of course, this can be achieved through other mechanisms, such as, camel route to copy the message in the processor. But using ActiveMQ's virtual destination is the best choice.
Practical Insights
To achieve this we need to modify activemq configuration file, named, activemq.xml. Here is my changes:
I have been bothered by Cygwin launching my my default shell as /usr/bin/sh. One big reason I don't like sh is that it does not have auto expand function, which to me is a life and death issue. So I decided to fix it.
First of all, you may ask this question:
How do I know which shell I am running?
It is a very good question, but the answer is simple. with the following command:
The reason for the problem I am having is that I didn't have the environment variable "SHELL" defined. Thus the solution is to add this variable in windows. Create a new environment variable SHELL with value of:
/usr/bin/bash
Addtional
You can launch window's system properties editor by using WinKey + Pause/Break.
Here are some interesting window keyboard shortcuts I use daily:
Windows Logo: Start menu
Windows Logo+R: Run dialog box
Windows Logo+M: Minimize all
SHIFT+Windows Logo+M: Undo minimize all
Windows Logo+F1: Help
Windows Logo+E: Windows Explorer
Windows Logo+F: Find files or folders
Windows Logo+D: Minimizes all open windows and displays the desktop
CTRL+Windows Logo+F: Find computer
CTRL+Windows Logo+TAB: Moves focus from Start, to the Quick Launch toolbar, to the system tray (use RIGHT ARROW or LEFT ARROW to move focus to items on the Quick Launch toolbar and the system tray)
Windows Logo+TAB: Cycle through taskbar buttons
Windows Logo+Break: System Properties dialog box
Application key: Displays a shortcut menu for the selected item
In terms of JMS, there are two types of messaging paradigms, namely, point-to-point, and pub-sub. The point-to-point paradigm uses queue. One or multiple publishers can send messages to a queue. Consequently, one or multiple consumers can consume messages either synchronously or asynchronously. I will cover this topic in my later blogging.
In this blogger, I am going to focus on the topic of pub-sub paradigm from practical point of view. I will cover the following aspects:
For a while, I have been thinking to blog my research and hand-on works. However, the out-of-box blogger's format cannot produce professional like results. In particular, if you want to put your code snippet by copy-and-paste, you will not get the right format.
Today, I decided to crack the shell and after some trial and errors, I found a way. I am pretty impressed with SyntaxHighlighter. Of course, I did my googling, and found few very useful links. However, even with the help, the trial and error tooks few hours to get right. Here is my notes on how I did it.
In order to use SyntaxHighlighter, we need to add the following code just before the tag:
Examples I
This sample is created using reference 1. In this example, I use the following tag:
//code goes here
package com.vha.esb.purej;
public class Context {
public String POLL_END_TIME = "2013-06-05 11:30:00.000";
public String POLL_START_TIME = "2013-06-05 12:00:00.000";
public String MEMID;
public String DP_340B_ID;
public String RX_SEQ_NUMBER;
}
Example II
This example use reference 2, but I typed the sample code. Also, I use
//code goes here
package com.vha.esb.purej;
for (int i = 0; i<10; i++)
{
int j = i
}
}
Example III
The following code are copied from eclipse and pasted to html page
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.example.osgi;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @version
*/
public class MyTransform {
private static final transient Logger LOG = LoggerFactory.getLogger(MyTransform.class);
private boolean verbose = false;
private String prefix = "MyTransform";
public Object transform(Object body) {
String answer = prefix + " set body: " + new Date();
if (verbose) {
System.out.println(">>>> " + answer);
}
LOG.info(">>>> " + answer);
return answer;
}
public boolean isVerbose() {
return verbose;
}
public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
}