Results 1 to 6 of 6
Thread: MessageDrivenBean
- 12-27-2010, 07:28 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
MessageDrivenBean
Following the payment method invocation (), the bean Shopping sends a message containing the amount to be paid and the customer's bank details (RIB) to a trusted part (TrustPayement). This injects the GestionBancaire and debit the balance amount of the corresponding customer.
Implement the MDB (TrustPayement) that provides this functionality.
------------------------
Frensh :
Suite à l’invocation de la méthode payement(), le bean Shopping envoie un message contenant le montant à payer ainsi que le RIB du client à une partie de confiance (TrustPayement). Ce dernier injecte le GestionBancaire et débite le montant du solde du client correspondant.
Implanter le MDB (TrustPayement) qui assure cette fonctionnalité.
-
- 12-27-2010, 09:53 PM #3
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
I have already two beans ( BankAccount and BankCustomer ) and a session ( BankManagement) //" GestionBancaire " in frensh
It's an e-commerce web site.
I need, now, how I impliment the method payement and how I imlements the message driven bean to ensure TrustPayement.
=)
- 12-27-2010, 10:31 PM #4
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
I have a pakage " ecommerce" contains two folders : 1)° beans ( BankAccount.java, BankCustomer.java, BankManagement.java and BankManagementRemote.java ) //BankManagement = " GestionBancaire " in frensh
2)° Customer ( Customer.java)
// customer = " client " in frensh
It's an e-commerce web site.
I need, now, know how I impliment the method payement and how I imlement the message driven bean to ensure TrustPayement.
=)
thank you
- 12-28-2010, 09:48 AM #5
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
this is what I've done
-----------------------------------------------
TrustPayement.java
----------------------------------------------
package TrustPayement.bean;
import java.util.StringTokenizer;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
import org.jboss.ejb3.annotation.Depends;
import javax.ejb.MessageDrivenContext;
import java.util.*;
@MessageDriven(activationConfig =
{
@ActivationConfigProperty(propertyName="destinatio nType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destinatio n", propertyValue="queue/exemple")//JNDI name
})
@Depends ("jboss.mq.destination:service=Queue,name=exempleM DB")
public class TrustPayement implements MessageListener
{
@EJB
private Gestion_bancaire.bean.GestionBancaire GB;
public void onMessage(Message recvMsg)
{
String msg="";
try{
msg=((javax.jms.TextMessage)recvMsg).getText();
StringTokenizer st=new StringTokenizer(msg,":");
String part1= Double.parseDouble( st.nextToken());
String part2= Long.parseLong(st.nextToken());
GB.Retrait_Argent(part1,part2);
}catch (javax.jms.JMSException e) {System.out.println("Erreur de reception");}
System.out.println("----------------");
System.out.println("Le message recu est : " + msg);
System.out.println("----------------");
}
}
------------------------------
this is my method
-------------------------------
public boolean paiement()
{
long RIB=1;
QueueConnection cnn = null;
QueueSender sender = null;
QueueSession session = null;
try
{
processMessage("queue/exemple");
InitialContext ctx = new InitialContext();
Queue queue = (Queue) ctx.lookup(queueBinding);
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
cnn = factory.createQueueConnection();
session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
TextMessage msg = session.createTextMessage(RIB+""+getTotal());
sender = session.createSender(queue);
sender.send(msg);
System.out.println("Message envoye avec succes a " + queueBinding);
}
finally
{
//cleanup
if (cnn != null)
{
cnn.close();
}
}
}
return true;
}
- 12-28-2010, 11:56 AM #6
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks