|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
message through out1 terminal using ROUTING:BEGIN ATOMIC |
« View previous topic :: View next topic » |
Author |
Message
|
rohank84 |
Posted: Fri Jan 30, 2009 1:48 am Post subject: |
|
|
Centurion
Joined: 31 Dec 2008 Posts: 109
|
hi davies
i cannot directly retrieve from cache table as i have to fire a query from cache table and the data retrieved from it will be different everytime ....i had thought of this before but it doesnt work in my case ....I will have multiple rows in my cache table ...so i will fetch a specific result from cache table through a query ..and there will always be 1 row returned from cache table....I cannot even change my original query to give one row as it will a kind of select * from table kind of query...
please help .... |
|
Back to top |
|
 |
rekarm01 |
Posted: Sat Jan 31, 2009 6:15 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
rohank84 wrote: |
hi davies
i cannot directly retrieve from cache table as i have to fire a query from cache table and the data retrieved from it will be different everytime ... I will have multiple rows in my cache table |
The problem is that the cache table won't have as many rows as you think it should, nor will it have the columns you're looking for. The purpose of the trace node was to point that out.
Presumably, your database table and cache table look something like:
Code: |
Database CacheQueueTable
.EMP_DETAILS .DestinationData[]
---------------------------------
email ---> TERMNO
name ---> portno
hostname |
Using a SHARED variable as a cache table can save the cost of a database lookup for every message, but you'll want to select all the rows you'll need up front.
Your first query:
Code: |
SELECT emp.email AS TERMNO, emp.name AS portno
FROM Database.EMP_DETAILS AS emp
WHERE emp.hostname = chardata |
... will only select one usable row, (where hostname=chardata), and it won't select the hostname column itself. You can lose the WHERE clause and some of the AS clauses:
Code: |
SELECT emp.email, emp.name, emp.hostname
FROM Database.EMP_DETAILS AS emp |
Your second query:
Code: |
SELECT emp.email AS TERMNO, emp.name AS portno
FROM CacheQueueTable.DestinationData[] AS emp
WHERE emp.hostname = chardata |
... won't select anything, as CacheQueueTable doesn't contain columns for email, name, or hostname. Assuming you fixed the first query, you can lose some AS clauses here too:
Code: |
SELECT emp.email, emp.name
FROM CacheQueueTable.DestinationData[] AS emp
WHERE emp.hostname = chardata |
If you lose the AS clauses, you'll need to adjust your assignments too:
Code: |
SET terminalnumber = Environment.Variables.TCPSEND.TCP.email;
SET portnumber = Environment.Variables.TCPSEND.TCP.name; |
But, putting all that aside, if you revisit the original problem statement, maybe you don't need any external databases, shared variables, SELECTs, ATOMIC blocks, or PROPAGATEs to multiple output terminals, after all:
rohank84 wrote: |
Actually i am making a TCP Application, there will be 1 send flow and multiple output flow (or receive flow)
Send Flow
FileInput -->Compute--> TCPClientOutput
Receive Flow
TCPServerInput --> FileOutput |
If all you need is to dynamically set the hostname and port number for a TCPClientOutput node, you can accomplish that with just a couple of SET statements:
Code: |
SET OutputLocalEnvironment.Destination.TCPIP.Output.Hostname = hostname; -- (where hostname=chardata)
SET OutputLocalEnvironment.Destination.TCPIP.Output.Port = portnumber; |
If the portnumber depends on the hostname, maybe you'll need to throw in a CASE function too. |
|
Back to top |
|
 |
rohank84 |
Posted: Mon Feb 02, 2009 1:16 am Post subject: |
|
|
Centurion
Joined: 31 Dec 2008 Posts: 109
|
hi rekarm01
u are absolutely write that i may not need to use propagate statement as only single TCPIPClientOutput serves the purpose. But i have to use shared variable as there will be different IP addresses passed to the TCPIPClientOutput which will come from firing a query in shared variable. I am using Atomic so that its becomes a kind of thread safe code.
I also got the point u said about the columns in shared variable i restuctured my original query to
Code: |
IF CacheQueueTable.valid IS NULL THEN
SET CacheQueueTable.DestinationData[] = (Select * from Database.EMP_DETAILS as emp);
SET CacheQueueTable.valid = true;
END IF; |
and i changed the assignments as well
Code: |
set OutputLocalEnvironment.Destination.TCPIP.Output.Hostname = the(Select emp.name from CacheQueueTable.DestinationData[] as emp WHERE emp.hostname = chardata);
SET OutputLocalEnvironment.Destination.TCPIP.Output.Port = the(Select emp.email from CacheQueueTable.DestinationData[] as emp WHERE emp.hostname = chardata); |
but sorry to say its not working ... i even tried putting the shared variable query into the environment variable like this
Code: |
set Environment.Variable.TCPSEND.TCP[] = Select emp.name,emp.email from CacheQueueTable.DestinationData[] as emp WHERE emp.hostname = chardata |
and changing the assigments to
Code: |
SET terminalnumber = Environment.Variables.TCPSEND.TCP.email;
SET portnumber = Environment.Variables.TCPSEND.TCP.name; |
but this is not working either.
1 thing im sure of is that if i want to set the TCPIP port and hostname dynamically then i have to set the COMPUTE MODE of compute node to MESSAGE..if i change it to LOCALENVIRONEMENT and MESSAGE then the code fails to set the port and hostname dynamically ........As i have seen the sample program that uses shared variable, the COMPUTE MODE is set to LOCAL ENVIRONMENT......So is this can be helpful to solve .. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Feb 02, 2009 3:35 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20767 Location: LI,NY
|
Well you can use message and localEnvironment modes on the compute node. However in this case you should not forget to copy the localEnvironment like you would the message from InputLocalEnvironment to OutputLocalEnvironment....
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
rohank84 |
Posted: Mon Feb 02, 2009 4:27 am Post subject: |
|
|
Centurion
Joined: 31 Dec 2008 Posts: 109
|
Hi
I am copying the input local environment to Output local environment
I am using log4j and i get the value in it but when i set the values for the hostname and portnumber then its doesnt work.....below is the esql
Code: |
SET OutputLocalEnvironment = InputLocalEnvironment;
ROUTING : BEGIN ATOMIC -- beginning of atomic block. Processing is single threaded until the END; is reached
IF CacheQueueTable.valid IS NULL THEN
SET CacheQueueTable.DestinationData[] = (Select emp.email,emp.name,emp.hostname from Database.EMP_DETAILS as emp WHERE emp.hostname = chardata);
SET CacheQueueTable.valid = true;
END IF;
--Fetching data from Cache Table
set OutputLocalEnvironment.Destination.TCPIP.Output.Hostname = THE(Select emp.name from CacheQueueTable.DestinationData[] as emp WHERE emp.hostname = chardata);
SET OutputLocalEnvironment.Destination.TCPIP.Output.Port = THE(Select emp.email from CacheQueueTable.DestinationData[] as emp WHERE emp.hostname = chardata);
set Environment.Variables.Log4j.LogText = THE(Select emp.name from CacheQueueTable.DestinationData[] as emp WHERE emp.hostname = chardata);
SET OutputRoot = InputRoot;
END ROUTING ; -- end of the ROUTING atomic block
|
here i get the value in log4j but when i set the values for hostname and port number it doesnt work ......wht cud be the reason or is there any other way of setting the cache table value in some kind of variable and then setting that variable in hostname and port number |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Feb 02, 2009 4:45 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20767 Location: LI,NY
|
Verify that your compute node is set for Message & LocalEnvironment
If changes to the OutputLocalEnvironment do not propagate it is very likely that your compute node is set for Message only...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
rohank84 |
Posted: Mon Feb 02, 2009 5:51 am Post subject: |
|
|
Centurion
Joined: 31 Dec 2008 Posts: 109
|
hi guys finally its solved...i put the cache query in the environment variable and removed all the alias from the original and cache query. I kept the compute mode MESSAGE....
Thanks a lot guys ...we had a very good conversation ....thanks a ton ! |
|
Back to top |
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|