Author |
Message
|
Prasi |
Posted: Fri Nov 15, 2013 8:50 am Post subject: Iterating through the global Cache |
|
|
Apprentice
Joined: 03 Aug 2011 Posts: 42
|
Hi,
How do I iterate through a global cache in IIB9.
For a general java map, we do as follows:
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println("Key = " + entry.getKey() + ", Value = " +
entry.getValue());}
But for MbGlobalMap how to iterate through the map because when I use the entrySet, it gives me error like The method entrySet() is undefined for the type MbGlobalMap... Can someone help me on this? |
|
Back to top |
|
 |
smdavies99 |
Posted: Sat Nov 16, 2013 3:43 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Take a look at the sample flows that use it. A really good starting point _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Prasi |
Posted: Sat Nov 16, 2013 2:19 pm Post subject: |
|
|
Apprentice
Joined: 03 Aug 2011 Posts: 42
|
Hi,
Could you please suggest me a example. I could not find one in help contents. I can find how to use the global cache in java compute node, how to configure etc.. but could not find one such example. If you have one, can you pls paste the link here. |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Nov 17, 2013 1:30 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Code: |
String[] value = (String[]) map.get(iata);
if (value == null) {
map.put(key, serials);
result[0] = "Ok[I]: key=("+ key + ") Value=" + serials[0];
} else {
map.update(key, serials);
result[0] = "Ok[U]: key=("+ key + ") Value=" + serials[0];
}
|
Not from a JCN but from Java code called from ESQL.
This in turn was directly cribbed from the sample code described in the IBM Redbooks/RedPapers on the subject. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
mqjeff |
Posted: Sun Nov 17, 2013 7:11 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
smdavies99 wrote: |
Code: |
String[] value = (String[]) map.get(iata);
if (value == null) {
map.put(key, serials);
result[0] = "Ok[I]: key=("+ key + ") Value=" + serials[0];
} else {
map.update(key, serials);
result[0] = "Ok[U]: key=("+ key + ") Value=" + serials[0];
}
|
|
That adds a single value to the map for a specific key.
It does not allow anyone to iterate over all keys in a given map. |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Nov 17, 2013 10:48 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
mqjeff wrote: |
That adds a single value to the map for a specific key.
It does not allow anyone to iterate over all keys in a given map. |
That is true. I was showing a possible use case for map.get.
However, I am actually coming round to the conclusion that with the V8 Broker the cache subset does not allow you to iterate over all the elements in a given map. I'm not sure about IB 9 though. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
|