Thursday, September 19, 2013

Websphere 8.5 Mediation Handler


Application Server: Websphere 8.5.5, RAD8.5,
Application: SampleMediation
What the application do: the application mediates any message coming on one destination to the other specified destination

Create Application Structure as below

>SampleMediation (EAr Project)
>SampleMediationEJB (ejb project)
>Mediation (java project)

Under Mediation Add a sample mediation handler as below:

public class FirstMediationHandler implements MediationHandler {
private String outDestination = "out.queue";
@Override
public boolean handle(MessageContext msgCtx) throws MessageContextException {
System.out.println("--incoming--");
SIMessageContext siMsgCtx = (SIMessageContext) msgCtx;
SIMessage originalMsg = siMsgCtx.getSIMessage();

//you do loads of thing, like transformation

List frp = new ArrayList(1);
   
        SIDestinationAddress dest = SIDestinationAddressFactory.getInstance().createSIDestinationAddress(outDestination, false);
frp.add(dest);
originalMsg.setForwardRoutingPath(frp);
System.out.println("--routed--");
return true;
}
}


>SampleMediationEJB (ejb project), add ejb-jar.xml and ws-handler.xmi
ejb-jar.xml should have following
<session id="FirstMediationHandler">
<ejb-name>FirstMediationHandler</ejb-name>
<local-home>com.ibm.websphere.sib.mediation.handler.ejb.GenericEJBMediationHandlerLocalHome</local-home>
<local>com.ibm.websphere.sib.mediation.handler.ejb.GenericEJBMediationHandlerLocal</local>
<ejb-class>com.ibm.websphere.sib.mediation.handler.ejb.GenericEJBMediationHandlerBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<env-entry>
<env-entry-name>mediation/MediationHandlerClass</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>com.vsp.test.FirstMediationHandler</env-entry-value>
</env-entry>
</session>



ws-handler.xmi should have the following

  <handler:EJBHandlerDD xmi:id="EJBHandlerDD1" name="FirstMediationHandler" description="" critical="true">
    <lists xmi:id="HandlerListRef1" listName="first_mediation" description="mediates from vcin_in to cch_in" sequence="1"/>
    <ejb xmi:type="ejb:Session" href="META-INF/ejb-jar.xml#FirstMediationHandler"/>
  </handler:EJBHandlerDD>


Thats it build the ear and do the setup as below.

Setup:
1) Create a local bus - bus1,
2) Create two destinations - out.queue and in.queue
3) Configure queues
- jms/out.queue for destination out.queue
- jms/in.queue for destination in.queue

4) Deploy the SampleMediation.ear

5) Create new Mediation in websphere,
Buses > bus1 > Mediations - create new, following values are entered
name = first_mediation
Handler list name = first_mediation


6) Mediate the destination
  Go to Buses > bus1 > Destinations > in.queue select it by clicking the checkbox
  and click the Mediate button on the top
 
7) Select Mediation
The mediation to apply to this destination = first_mediation

8) The mediation would be up and working and any message coming on the in.queue is routed to out.queue







Wednesday, May 29, 2013

Websphere 8.5 + EJB3.1 Interpreting error logs

Injection (@Inject) would not work. Following error is reported.

 000000bc InjectInjecti E   CWOWB0102E: A JCDI error has occurred: JCDI runtime cannot resolve @Inject java.lang.reflect

solution:  Went and look in to ffdc logs and found that Entities were not correctly created and hence the whole ORM was failing to load up.  fixed the ORM objects (mapping etc) and issue get resolved

Friday, March 29, 2013

Minimize the Carbon foot print.


Minimize the Carbon foot print.

It would be very hard to conveince the goverment to lay down the rules to protect the envrioment, as this would lead this article to a wrong directions.  But we as grown-up always worry about future of our children and grand-childrens.  We want to save money for there education, save real-estate or property for there living, save on retirement but have ever thought of saving oxygen or this environment on which we depend.   Have we ever made a small decission that i would not use plastic - no matter what happens.  Frankly tell me what are the implications that we stop using plastic bottles, plastic bags, plastic boxes,  - this would not make lay-offs but this would rather increase the job market as the vary company producing this would have to invest in to producing degradable bags, boxes, bottles - more jobs and less danger to environment and our future.

I totally agreee that taking plastic off completely is not possible, but we can minimize the use.  
Here are some way to do that
1) after you done grocerry shopping please ask them to use Paper Bags - as the bags are generally thrown away once the  Items reach home.

2) Generally carry a reusable water bottle - saying no to “Plastic bottled Water” but we can refill it using the “Big Water Dispenser”  - every thing supplied from the same company who makes the “plastic bottled water”.

3) Please say no to StyroFoam (Polystyrene)  - cups or glasses - this Styrofoam is very hard material and would not degrade easily.  Please search online to findout why i am asking not to use this.  Let companies making them innovate themselves as one Water-company supplying bottled water to us already started supplying “small - paper cups” which is used to drink water and then discard.  
The cups - glasses are used for hot/cold beverages,water, ice etc etc, but one can have there own “Mug” and reduce it use.

4)  we can use Paper plates & bowls instead of styrofoam plates & bowls.

5) Recycle - yes i do agree that in gettogether, parties,picnics we cannot do it with out plastics forks, knifes, spoons but please recycle them. Ask the people to seperate them out when discarding.

To minimize cabron footprint - heres  a list of things you can do