Thursday, January 30, 2014

Virtual Destination

Why Virtual Destination

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:


        
             
                    
                           
                                   
                                       
                                       
                                   
                           
                      
             
       


Reference

http://activemq.apache.org/virtual-destinations.html

Tuesday, January 21, 2014

How To Luch Cygwin Shell with bash

The Issue

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:
   ps -eaf
You should see the following:
# ps -eaf
     UID     PID    PPID TTY     STIME COMMAND
    gliu   12188       1   ?  14:34:09 /usr/bin/mintty
    gliu   11764   12188   0  14:34:09 /usr/bin/sh
    gliu   12192   11764   0  14:39:53 /usr/bin/ps

Solution

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

Messaging With Topic Explained

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:
  • How to publish message to a topic
  • How to subscriber message from a topic
  • How broker handles the message
  • What is a durable subscriber
  • What does it mean to persistent messages
  • Best proactices

Sunday, January 19, 2014

Setup SyntaxHighlighter For Google Blogger

Introduction

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.

I have also created a video for this at youtube: http://www.youtube.com/watch?v=Wl0bpEK_rQQ

Quick Reference List


Here are the reference I used:
  1. Use this one if you want publish simple code
  2. This is will really work!

Update Blogger Template


Simple Code Format


Add the following css code just before the end of tag:
.code { 
background:#f5f8fa; 
background-image:none; 
background-repeat:no-repeat; 
border: solid #5C7B90; 
border-width: 1px 1px 1px 20px; 
color: #000000; 
font: 13px 'Courier New', Courier, monospace; 
line-height: 16px;
margin: 10px 0 10px 10px; 
max-height: 200px; 
min-height: 16px; 
width: 00px
overflow: scroll; 
padding: 28px 10px 10px; width: 90%; 
} 
.code: hover { 
background: #FAFAFA; background-image:none; 
background-repeat:no-repeat; 
}

Looks Like Professional

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;
    }
}

Anypoint Studio Error: The project is missing Munit lIbrary to run tests

Anypoint Studio 7.9 has a bug. Even if we following the article: https://help.mulesoft.com/s/article/The-project-is-missing-MUnit-libraries-...