how to call procedure in database asynchronously from java 1.4 code? - asynchronous

platform:
Sql server 2000
java 1.4
ejb 3.0

I'm not sure to get the question but calling a stored procedure involves using a CallableStatement. For the asynchronous part, and because you mentioned EJBs, the standard way would be to use JMS and a Message Driven Bean. But I'm a bit confused by the part where you mention Java 1.4 and EJB 3.0 (that requires Java 1.5). Maybe you should clarify that requirement. Sending JMS messages to a MDB 3.0 from a Java 1.4 client should be possible though.

If you don't find a way to handle this at database level, you can do it like you would do any asynchronous stuff:
thread = new Thread() {
public void run() {
// do your procedure call here
}
};
thread.start();

Related

Read existing messages from a Subscription/Topic in Azure ServiceBus

I am trying to read all existing messages on an Azure ServiceBus Subscription, using the Microsoft.Azure.ServiceBus.dll (in .Net Core 2.1) but am struggling.
I've found many examples that the following should work, but it doesn't:
var client = new SubscriptionClient(ServiceBusConnectionString, topicName, subscription, ReceiveMode.PeekLock, null);
var totalRetrieved = 0;
while (totalRetrieved < count)
{
var messageEnumerable = subscriptionClient.PeekBatch(count);
//// ... code removed from this example as not relevant
}
My issue is that the .PeekBatch method isn't available, and I'm confused as to how I need to approach this.
I've downloaded the source for the ServiceBusExplorer from GitHub (https://github.com/paolosalvatori/ServiceBusExplorer) and the above code example is pretty much as it's doing it. But not in .Net Core / Microsoft.Azure.ServiceBus namespace.
For clarity though, I'm trying to read messages that are already on the queue - I've worked through other examples that create listeners that respond to new messages, but I need to work in this disconnected manner, after the message has already been placed on the queue.
ServiceBusExplorer uses WindowsAzure.ServiceBus Library, which is a .Net Framework Library and you cannot use it in .Net Core applications. You should use Microsoft.Azure.ServiceBus (.Net Standard Library) in .Net Core applications.
Check here for samples of Microsoft.Azure.ServiceBus
var client = new SubscriptionClient(ServiceBusConnectionString, topicName, subscription, ReceiveMode.PeekLock, null);
client .RegisterMessageHandler(
async (message, token) =>
{
await subscriptionClient.CompleteAsync(message.SystemProperties.LockToken);
}
);
Try using RegisterMessageHandler. It will
receive messages continuously from the entity. It registers a message handler and
begins a new thread to receive messages. This handler is awaited
on every time a new message is received by the receiver.

Spring Integration: JDBC single query to web service

I would like to know the way for resolving this integration scenario:
Execute different queries to select X elements from a database. I am
looking for an inbound adapter without pooling because it is just
necessary to execute the query once. Although, results of the queries
will be generate only one output.
Work with this data to build a SOAP request (generic web service)
Send this SOAP request to a web service and wait for an asynchronous response.
But also, it is necessary to deploy all this scenario in a WAR file on Tomcat server. I am deploying the application from a spring MVC + spring integration skeleton but I will not have any controller. Is it possible to execute the application when context was loaded on Tomcat?
I am working with the next technologies:
Spring integration
Spring MVC for a WAR deployment
Scheduling (Quartz or #Scheduled)
Spring WS
Regards
Since you say that you'd prefer to select on the application start up and only once, you can use:
<int-event:inbound-channel-adapter channel="jdbcChannel"
event-types="org.springframework.context.event.ContextRefreshedEvent"
payload-expression="''"/>
and <int-jdbc:outbound-gateway query="SELECT * FROM ..."/>
And so on to the WebService.
UPDATE
Since you say that you are around Anotation configuration, consider to use Spring Integration Java DSL.
To configure <int-event:inbound-channel-adapter> from #Configuration you should do this:
#Bean
#SuppressWarnings("unchecked")
public MessageProducer ApplicationEventListeningMessageProducer() {
ApplicationEventListeningMessageProducer producer = new ApplicationEventListeningMessageProducer();
producer.setEventTypes(ContextRefreshedEvent.class);
producer.setPayloadExpression("''");
producer.setOutputChannel(jdbcChannel());
return producer;
}
ContextRefreshedEvent info you can get from its JavaDocs or from Spring Framework Manual.

sap .net connector 3.0 idoc processing

I need to implement Idoc processing with SAP .net connector 3.0
I'm looking for C# exemples. I didn't find any help into SAP .net connector 3.0 library: SAP.Middleware.Connector !!! Amazing: no reference at all on IDOC implementation !
old classes used in SAP .net connector 2.0 (such as SAPIDocReceiver) seem to have been removed from this new version.
i heard about 'IDOC_INBOUND_ASYNCHRONOUS' method (or class ?) which should be used in SAP .net connector 3.0 ?
thanks to all, any help appreciated
You might consider to act as a RFC Server in NCO 3.0 and handle either 'IDOC_INBOUND_IN_QUEUE' and/or 'IDOC_INBOUND_ASYNCHRONOUS'.
[RfcServerFunction(Name = "IDOC_INBOUND_IN_QUEUE")]
public static void IDOC_INBOUND_IN_QUEUE(RfcServerContext serverContext, IRfcFunction rfcFunction)
{
//Create table to handle control records
IRfcTable irtControl = rfcFunction.GetTable("IDOC_CONTROL_REC_40");
//Create table to handle data records
IRfcTable irtData = rfcFunction.GetTable("IDOC_DATA_QUEUE");
//Process tables
//
//Confirm receipt of IDoc
//BAPI call back to SAP to confirm if needed
}
This site may be of value http://www.dataxstream.com/

Migration from Flex 3 to Flex 4.5: problem with network format

I'm currently migrating a large project from Flex 3 to Flex 4.5. The problem I'm stuck on is network communication: we're using a custom protocol that we embed in AMF3, but it seems the messages sent by flash.net.NetConnection aren't readable.
Our Java back-end uses some BlazeDS classes to deserialize the message, namely flex.messaging.io.amf.AmfMessageDeserializer.AmfMessageDeserializer, and I can monitor the network traffic with Charles Web Proxy which decodes AMF3. The very simple code herebelow sends a message that can be decoded by Charles when compiled in Flex 3.5, but not in Flex 4.5 (I get "Failed to parse data (com.xk72.amf.AMFException: Unsupported AMF3 packet type 17 at 26").
import mx.controls.Alert;
private function init():void
{
var pdl : Dictionary = new Dictionary();
var connection : NetConnection = new NetConnection();
connection.connect("http://localhost");
var responder : Responder = new Responder(result);
connection.call("net", responder, pdl);
}
private function result(pdl : Object) : void {
Alert.show("coucou", "hello");
}
I've set up an apache server at localhost:80 to test this.
Has anyone used NetConnection in Flex 4.5 and encountered deserialization problems? How did you solve them?
Thanks,
Daniel
AMF3 has a bunch of different core types it can serialize. One of those core types is new to AMF3 in the past year or two, Dictionary, and it has a "packet type" of 17, thus the error message. I'm not sure why Flex 3 would serialize it as something other than a Dictionary and Flex 4.5 would serialize it as the new Dictionary type, but you're getting an error because your BlazeDS backend doesn't support the new Dictionary type.
The solution is to either figure out what it was sending as in Flex 3 and switch to that, or to upgrade BlazeDS (there seems to have been a patch added to BlazeDS last year for Dictionary http://forums.adobe.com/thread/684487).
edit: Didn't realize that the error was with Charles. Charles probably hasn't added support for Dictionary, as it's not part of the documented AMF3 specs. Have you tried the beta of Charles?
Since you're working with legacy code, you may need to set the NetConnection's objectEncoding property manually before you make the connection. You can set the connection's objectEncoding with the help of the ObjectEncoding class.
What version of Flash Player are you using?

How to use AIR 2.0 NativeProcess API with Java?

How do you use this great new API in connection with Java? Do you use just pure native process API like nativeProcess.standardInput.write() and nativeProcess.standardOutput.read() with which you cannot debug Java side neither invoke remote java method. Or you are using some library that leverages remote method invocation such as flerry lib but that also cannot debug Java side? Or maybe you are using Merapi with which you can debug but cannot remotely invoke Java method? I'm asking this because this is maybe the most important question regarding this API and its ease of use.
It sounds like your reservations have to do with being able to debug the Java process. This is not really an issue. You can use the NativeProcess API to kick off a Java process with arguments that will cause it to be externally debuggable. For example:
var processArgs:Vector.<String> = new Vector.<String>();
processArgs.push("-Xdebug");
processArgs.push("-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n");
This will allow your Java process to be remote debuggable. You can then connect to it from Eclipse or Netbeans once the process has started. If the code in the Java process is linked to an active Eclipse/Netbeans project, you can do linewise debugging like you would of any other Java application.
-Raj
You can use NativeProcess to execute java.exe and pass it the right parameters to execute a java application.
You cannot use NativeProcess to run random java code from a jar file.
Having used both of them, you can debug the JVM with MerAPI or NativeProcess API.
Prior to AIR2.0, I used merapi to communicate over the network to a java process.
I would much prefer to use the NativeProcess launcher now, with MerAPI we were hacking
ugly marshalling code. Debugging the network payloads was a pin via merapi.
Using NativeProcess API is easy -
var myForkedExe:NativeProcessStartupInfo = new NativeProcessStartupInfo();
myForkedExe.executable = ;
...
I am not sure I understand what you mean by can not invoke remote Java methods with merapi.
That's exactly what I have been doing. Debugging is easy, just set the JPDA args and attach any JAVA debugger.
You could use Flerry to launch and communicate with java processes.
You can use var file:File = new File("/usr/bin/java"); and pass parameters to the Java-file with a Vector of arguments. E.g.
var arguments:Vector.<String> = new Vector.<String>;
arguments.push("-jar");

Resources