Home » Other » General » How to pass Data as XML Messages using MQ - Series ? (Financial,3,unix/window,oracle 9i)
How to pass Data as XML Messages using MQ - Series ? [message #283486] Tue, 27 November 2007 05:35 Go to next message
tapaskmanna
Messages: 98
Registered: January 2007
Location: Cyprus,Nicosia
Member
How to pass Data as XML Messages using MQ - Series ?
Re: How to pass Data as XML Messages using MQ - Series ? [message #283489 is a reply to message #283486] Tue, 27 November 2007 05:43 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
How is this an Oracle question?

Regards
Michel
Re: How to pass Data as XML Messages using MQ - Series ? [message #283491 is a reply to message #283489] Tue, 27 November 2007 05:46 Go to previous messageGo to next message
tapaskmanna
Messages: 98
Registered: January 2007
Location: Cyprus,Nicosia
Member


How to pass Data as XML messages using Advance Queue ?
i.e
(i) Extracting records as XML.
(ii) Passing those XML using Message Queue (Advance
Queue).

Re: How to pass Data as XML Messages using MQ - Series ? [message #283495 is a reply to message #283486] Tue, 27 November 2007 05:52 Go to previous messageGo to next message
scorpio_biker
Messages: 154
Registered: November 2005
Location: Kent, England
Senior Member
Hi,

Try this link Java Message Service, it might help.
Re: How to pass Data as XML Messages using MQ - Series ? [message #283503 is a reply to message #283495] Tue, 27 November 2007 06:00 Go to previous messageGo to next message
tapaskmanna
Messages: 98
Registered: January 2007
Location: Cyprus,Nicosia
Member


Can you tell by using Advance Queues ?
icon12.gif  Re: How to pass Data as XML Messages using MQ - Series ? [message #283682 is a reply to message #283503] Tue, 27 November 2007 23:38 Go to previous message
ashirwada
Messages: 1
Registered: November 2007
Junior Member
import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;
import oracle.xml.sql.query.*;

// Java code for Sending messages to sonic MQ(4.0.2). Program need to change for following
// Queuename eg SampleQ2
// UserName
// PassWord
// HostUrl eg server:2506



public class XMLTESTMESSAGE
{
public XMLTESTMESSAGE() {
}

// Second Constructor
public XMLTESTMESSAGE(String clientId) {
setId(clientId);
}

// Third Constructor
public XMLTESTMESSAGE(String clientId, String clientName) {
setId(clientId);
setName(clientName);
}

public String getId() {
return clientId;
}

public void setId(String clientId){
this.clientId = clientId;
}

public String getName() {
return name;
}

public void setName(String name){
this.name = name;
}

private static String QueryName = "SELECT * FROM SALES" ;
private static String clientId = "99";
private static String name = "Customer";

private static final String broker = "10.100.121.185:2506";
private static final String password = "password";
private static final String sQueue = "SampleQ2";
private static final String username = "mike";
private static final int MESSAGE_LIFESPAN = 1800000; // milliseconds (30 minutes)

private javax.jms.QueueConnection connect = null;
private javax.jms.QueueSession session = null;
private javax.jms.QueueSender sender = null;

// Create JMS client for publishing and subscribing to messages.
private void talker( String broker, String username, String password, String sQueue, String CustNum, String CustName ,String QueryName)
{
// Create a connection.
try
{
javax.jms.QueueConnectionFactory factory;
factory = (new progress.message.jclient.QueueConnectionFactory (broker));
connect = factory.createQueueConnection (username, password);
session = connect.createQueueSession(false,javax.jms.Session.AUTO_ACKNOWLEDGE);
}
catch (javax.jms.JMSException jmse)
{
System.err.println("error: Cannot connect to Broker - " + broker);
jmse.printStackTrace();
System.exit(1);
}

// Create Sender queue
try
{
if (sQueue != null)
{
javax.jms.Queue sendQueue = session.createQueue (sQueue);
sender = session.createSender(sendQueue);
connect.start();
}
}
catch (javax.jms.JMSException jmse)
{
jmse.printStackTrace();
exit();
}

try
{ Connection conn = null;

while ( true )
{
// Note that the XMLMessage is a Sonic Software extension
progress.message.jclient.XMLMessage xMsg = ((progress.message.jclient.Session) session).createXMLMessage();
StringBuffer msg = new StringBuffer();
// register the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// obtain the default connection as scott/tiger
conn = DriverManager.getConnection("jdbc:oracle:thin:@dbyrk01:1521:METPD", "met", "met");
// create any subsequent statements as a REF CURSOR

((OracleConnection)conn).setCreateStatementAsRefCursor(true);

// create the statement
Statement stmt = conn.createStatement();

// do a simple query

// ResultSet rset = stmt.executeQuery("select sys.dbms_xmlquery.getXML('select total_amount from sales where order_code = 1501') XMLDATA from dual");

OracleXMLQuery qry = new OracleXMLQuery(conn,QueryName);

String xmlstring = qry.getXMLString();

msg.append(xmlstring);


xMsg.setText( msg.toString() );
// Queues usually are used for PERSISTENT messages.
// Hold messages for 30 minutes (1,800,000 millisecs).

sender.send( xMsg,
javax.jms.DeliveryMode.PERSISTENT,
javax.jms.Message.DEFAULT_PRIORITY,
MESSAGE_LIFESPAN);
exit();
}
}
catch ( javax.jms.JMSException jmse )
{
// Any undeliverable messages should be captured here.
// Perhaps JDBC could be used to update a database, write to a log file, etc.

System.out.println("Unable to send Message for Client:" + name);
jmse.printStackTrace();
}
catch (SQLException sqle)
{

sqle.printStackTrace();
}

// Close the connection.
exit();
}


// Cleanup resources and then exit
private void exit()
{
try
{
connect.close();
}
catch (javax.jms.JMSException jmse)
{
jmse.printStackTrace();
}

System.exit(0);
}

// Main program entry point
public static void main(String argv[]) {
String QueryStr = null ;

// Check parameters
for (int i = 0; i < argv.length; i++) {

String arg = argv[i];

System.out.println(arg);

QueryStr = arg;
System.out.println(QueryStr);
continue;
}

/* if (arg.equals("-cu")) {
if (i == argv.length - 1 || argv[i+1].startsWith("-")) {
System.err.println("error: missing customer number parameter");
System.exit(1);
}
clientId = argv[++i];
continue;
}

if (arg.equals("-cn")) {
if (i == argv.length - 1 || argv[i+1].startsWith("-")) {
System.err.println("error: missing customer name parameter");
System.exit(1);
}
name = argv[++i];
continue;
}
}
*/

// Start the JMS client for the "Talk".
XMLTESTMESSAGE talk = new XMLTESTMESSAGE();
talk.talker (broker, username, password, sQueue, clientId, name,QueryStr);

}

}/*@lineinfo:generated-code*/
Previous Topic: Announcements at OpenWorld 2007
Next Topic: Oracle Linux/Virtualization Software
Goto Forum:
  


Current Time: Fri Dec 09 13:54:42 CST 2016

Total time taken to generate the page: 0.12984 seconds