I'm embedding JRuby in a java library on a web application using concurrent mode (Single Ruby Runtime), should instantiate one ScriptingContainer per request, or reuse the same instance of the ScriptingContainer in all requests ?
Related
I m using apache qpid as a broker for writing junits. My use case requires to use delayed message functionality in tests. so does qpid supports this , like rabbitmq. I s there any plugin available which i can write in qpid json file.
I assume since your question is tagged 'junit' you are writing your unit tests in Java and are probably embedding the Apache Qpid Broker-J.
Delivery delay is supported. You don't need a plugin. It is described here:
https://qpid.apache.org/releases/qpid-broker-j-7.0.6/book/Java-Broker-Concepts-Queues.html#Java-Broker-Concepts-Queue-HoldingEntries
As discussed in the document, you must turn on the feature at the queue level and from the client side indicate your wish for the delivery to be delayed. To do this pass a message annotation (if using AMQP 1.0) or a message header (if using the older AMQP protocols).
If you are using the JMS 2.0 compatible client life is easy. Access the feature via the JMS 2.0 API MessageProducer#setDeliveryDelay() or JMSProducer#setDeliveryDelay().
I need to make a Windows Store application that exchanges xml serialized data over a TCP connection with a server. Since I need to use Direct3D rendering in the application I went for the c++/cx store application template however I ran into issues with xml serialization/deserialization.
My usual approach in C# would be to use the XmlSerializer and classes with DataContractAttribute annotations. However as soon as I try to import System.Xml.Serialization assembly I get the C1114 error - WinRT does not support #using of a managed assembly. However there are lots of examples that mention using this approach in a Windows Phone app from C#.
So the question is - is only c++/cx limited in support for .NET in Windows Store applications and C# can use all the standard components on phone as well or is switching to C# in this case also not a solution and I need to use the WinRT classes for xml serialization/deserialization?
Your confusion is understandable, what with the variety of frameworks Microsoft has put out there.
C++/Cx is a native binding to the Windows Runtime (WinRT). It does not use any managed code or the .NET framework in any way, which is why you're getting the C1114 error.
C# provides a managed binding to WinRT. It does leverage the .NET framework, so in a C# Windows Store application, you can make use of some of the base-class library. This subset is referred to as the .NET Profile. This article talks about this more: http://blogs.msdn.com/b/dotnet/archive/2012/04/17/net-for-metro-style-apps.aspx
In your specific case, you are using a C++/Cx application because you want access to Direct3D. This makes sense, although it means that you will not have access to System.Xml.Serialization. Instead, as you surmised, you will need to use APIs that are available to C++/Cx to read XML, specifically Windows.Data.Xml.Dom: https://msdn.microsoft.com/en-us/library/windows/apps/windows.data.xml.dom.aspx
Our RESTful application need to support 'partial responses' to limit bandwith.
By this I mean that the REST client tells the URI service which fields of the resource it is interested in.
For instance: api/v1/users/123/fields=firstName,lastName,birthDate
We're using Jackson parser to convert our DTO's to a JSON structure.
The problem is that we cannot tell at runtime to 'skip' some properties.
We should need to create a class at runtime with a variable amount of properties to accomplish this. But I don't think this is possible in Java, it is a static language after all.
While searching the internet we found some semi-solutions by just returning a java.util.Map containing the requested properties or filtering out properties by the Jackson parser.
Especially the latter seems a 'hacking solution' to me. It seems that Spring MVC doesn't provide an out-of-the-box solution for this issue...
Is there any alternative in the Java world we can use to solve this issue?
How about Yoga
Yoga extends JAX-RS and SpringMVC RESTful servers to provide GData and LinkedIn style field selectors.
Choose which fields you want to see at call-time
Navigate entity relationships in a single call for complex views
Much faster speeds in high-latency (e.g. mobile) apps
Streamline client development
Browsable APIs
I have an AIR application, which must somehow interact with C# application on desktop, ( it must generally receive data which C# application extracted from MSSQL database ).
Is it possible this interaction and how ?
lots of ways. the most simple is to connect a tcpip connection, and communicate the data via localhost. this way you'll later be able to move the app.
public function connectToServer(ip:String="127.0.0.1", port:Number=65045):void {
trace("connect")
theSocket=new Socket(ip, port);
theSocket.connect(ip,port);
theSocket.addEventListener(IOErrorEvent.IO_ERROR, ioerrorEvent)
theSocket.addEventListener(ProgressEvent.SOCKET_DATA,Getdata);
theSocket.timeout=10*60*60*1000 //10 minutes
}
i suppose you'll know the c# side.
also you can make a file what both apps will read/write, you can use extensions, so one app will be contained by the other, etc..
You could bake in some native code libraries into your AIR app to talk to the other app or even better, take the functionality of that C# app merge it as native code into your AIR app so you can talk to MySQL directly. Good Luck!
http://help.adobe.com/en_US/air/build/WS597e5dadb9cc1e0253f7d2fc1311b491071-8000.html
I am trying to profile my app to see where I can tweak memory management and speed. I have read into Garbage collection and I am trying to use
GC::Profiler.enable
In my app. However when I call this in Jruby I am getting a
org.jruby.exceptions.RaiseException: (NameError) uninitialized
I know that the garbage collection is done in the JVM on Jruby - so this might be why it is not initialized Which makes sense, what is the alternative to use in Jruby?
That's a MRI specific API - there's not an API equivalent for JRuby probably due the way the JVM works (there are multiple GC strategies with most VMs and there's no consistent API to work with the GC, even a System.gc() call does not necessary trigger garbage-collection immediately).
But there's a standart monitoring API (called MX) available for Java applications and since your JRuby app is a Java app you can use those, of course you might need to understand some of the internals e.g. how your ruby classes are seen by the JVM, but it ain't that hard.
Try starting here: http://www.engineyard.com/blog/2010/monitoring-the-jvm-heap-with-jruby/
Here's a summary of Java tools available you can use with JRuby as well: http://blog.headius.com/2010/07/browsing-memory-jruby-way.html
Don't forget to check the wiki as well, e.g. there's a page on profiling object allocations:
https://github.com/jruby/jruby/wiki/Profiling-Object-Allocations