ActiveMQ似乎不允许队列中的消息驱逐(ActiveMQ doesn't seem to allow for message eviction in queues)
目前,我正在使用一种设置,其中ActiveMQ用于以持久的方式控制许多消费者和许多生产者之间的消息处理。
我正在试图找出一种可以分叉队列的方法,这样我就可以有一个生产队列和一个用于分析/诊断目的的副本。 我发现制作复合队列似乎是为了满足这种需求。 生产数据可以继续正常流动,而我关心的消息是重复的,供我使用。
我对这种方法的问题在于可靠性。 我不希望分析/诊断过程阻止生产数据流,并且我也不希望ActiveMQ耗尽内存,如果消息得到备份,或者分析/诊断服务脱机。 对我来说,最好的选择是如果消息已满,消息将从分析/诊断队列中删除。
constantPendingMessageLimitStrategy可以完美地用于我的目的,但是从我从一些邮件列表中读到的内容(在尝试使其工作失败之后)是它仅支持主题。 消息TTL对我来说也不起作用(据我所知),因为该设置附加到生产者我只希望到期/丢弃/驱逐只发生在非生产队列上。
我正在尝试做什么选择?
Currently, I'm working with a setup where ActiveMQ is being used to control message processing between many consumers and many producers in a durable fashion.
I'm trying to figure out a way that I can fork the queue, such that I can have a queue for production and a copy for analytic/diagnostic purposes. I've found that making a composite queue seems to be made for this need. Production data can continue flowing normally, while the messages I care about are duplicated, for my use.
The problem I have with this approach is around reliability. I do not want the analytic/diagnostics process to block the production data flow, and I also do not want ActiveMQ to run out of memory, if messages get backed up, or the analytic/diagnostics service goes offline. For me, the preferable option is that the messages get dropped out of the analytic/diagnostics queue if it is full.
The constantPendingMessageLimitStrategy would work for my purposes perfectly, but from what I've read from some mailing lists (after trying to get it to work unsuccessfully) is that it is only supported for topics. Message TTL also does not work for me (from what I can tell), because that setting is attached to the producer I only want expiry/drop/eviction to only happen on the non-production queue.
What are the options for what I'm trying to do?
原文:https://stackoverflow.com/questions/24684548
最满意答案
您可以围绕Reflection创建自己的Java包装器,它调用反射API并从JNI而不是反射API调用它。 这将是更轻量级的解决方案。
You can create your own Java wrapper around Reflection which calls reflection API and call it from JNI instead of reflection API. This would be much lighter weight solution.
相关问答
更多-
你的实现问题是jstring数据成员。 NewStringUTF()创建一个Java String对象以从JNI方法返回。 所以这是一个Java本地引用。 但是,您将它存储在C ++对象中,并尝试在JNI调用中使用它。 您应该更好地区分C ++对象,Java和它们之间的JNI接口。 换句话说,C ++应该使用C ++方式来存储字符串(如std::string )。 InvokeNativeFunction()的JNI实现应该将其转换为一个jstring作为返回值。 PS:有些情况下需要C ++实现来保持对J ...
-
明显的问题是pax_store_get_data_avail_info()不是DataAvailable的方法。 这是其他一些类的方法吗? 你实际上并没有说它是什么。 但我们假设它是: class X { public native int pax_store_get_data_avail_info(DataAvailable[] stats_array); } 当你调用这个方法时,你得到的jclass jclass1参数是“X”,而不是DataAvailable。 因此,您对GetMethodID ...
-
对cout和printf C ++调用不会显示在LogCat输出中。 有两种解决方案。 使用NDK提供的记录宏允许您将消息记录到LogCat。 这对于您正在编写的新代码和包装代码很有用,但是当您拥有一个充满现有调试语句的库时不太好。 我将宏定义如下: #define LOG_INFO(info) __android_log_write(ANDROID_LOG_INFO,"JNI",info) #define LOG_ERROR(error) __android_log_write(ANDROID_LOG_E ...
-
我曾经使用命令行来做。 转到源文件目录。 javac filename.java生成filename.class文件。 javah filename生成filename.h文件。 您可以参考javac和javah获取更多帮助。 I used to do it using command line. go to the source file directory. javac filename.java to generate filename.class file. javah filename to ge ...
-
JNI上的Java对象(Java Objects on JNI)[2023-01-15]
实际上,我解决了它: JNIEXPORT jobject JNICALL Java_com_rmsdk_wrapper_RMServices_getBookmarkNew( JNIEnv *env, jobject thiso) { jclass cls = g_jniEnv->FindClass("br/com/iba/model/Annotation"); jobject obj = g_jniEnv->AllocObject(cls); jmethodID meth1 = ... -
当然。 它实际上比链接的例子要容易得多,因为你不必生成一个JVM来完成它 - 调用你的java函数为你提供了一个指向你可以使用的环境的指针。 举个简单的例子:使用这样的Java类: public class foo { static { // load libfoo.so / foo.dll System.loadLibrary("foo"); } private native void nativecall(); public static void main(Stri ...
-
在JNI中使用接口(Using Interfaces in JNI)[2023-05-18]
RegisterNatives不添加新的本地方法,它为类中现有的本地方法注册本地函数。 如果有人没有为本地方法调用RegisterNatives,那么当第一次调用方法时, JVM将搜索所有DLL库的实现。 因此,添加implements Listener ,用native关键字编写定义并将其实现RegisterNatives到RegisterNatives 。 RegisterNatives doesn't add new native methods, it registers native functi ... -
您可以围绕Reflection创建自己的Java包装器,它调用反射API并从JNI而不是反射API调用它。 这将是更轻量级的解决方案。 You can create your own Java wrapper around Reflection which calls reflection API and call it from JNI instead of reflection API. This would be much lighter weight solution.
-
从Android Java调用本机函数 - 替代JNI(Calling native functions from Android Java - alternative to JNI)[2021-03-28]
我不相信有一个更优雅的解决方案,而不是你为库编写JNI包装器的建议。 无论如何,这可能不是一个好主意,因为您应该为要支持的每个体系结构编译所有本机代码的单独版本。 只是附加到已编译的库意味着你被它的架构所困扰。 I do not believe there is a more elegant solution than the one you suggested of writing a JNI wrapper for the library. It is probably not a good idea ... -
重载JNI方法(Overload JNI Method)[2023-01-11]
在Java文件上运行javah ,声明本机方法,您将看到需要两个不同的Java_com_xxx函数。 C级声明必须是唯一的。 Run javah on your Java file declaring the native methods and you will see that you need two different Java_com_xxx functions. The C-level declarations must be unique.