问题列表 - 第24589页

RabbitMq是否从交换机到队列进行循环

我目前正在评估消息队列系统,RabbitMq似乎是一个很好的候选者,所以我正在深入研究它.

为了给出一些上下文,我希望有一个类似于一个交换负载的东西来平衡消息发布到多个队列.我不想复制邮件,因此不能选择扇出交换.

另外我之所以考虑拥有多个队列而不是一个队列来处理与消费者的循环,我不希望我们的单点故障处于队列级别.

听起来我可以在发布者端添加一些逻辑来通过编辑路由键并具有适当的绑定来模拟该行为.但这种被动方法不会考虑每个队列上的消息消耗速度,如果该队列的消费者应用程序已经死亡,可能会导致填满一个队列.

我正在寻找一种来自交换实体方面的更主动的方式,它将根据每个队列大小或某种性质决定在何处发送下一条消息.

我读到了Alice和可用的RESTful API,但这似乎是实现快速路由决策的重要解决方案.

任何人都知道如果在交换队列之间循环是否可行,那么RabbitMQ呢?谢谢.

messaging message-queue rabbitmq

10
推荐指数
1
解决办法
2596
查看次数

具有旧NSData维护字节范围的新NSData

我有一个相当大的NSData(或NSMutableData,如果有必要)对象,我想从一个小块中取出并离开其余部分.由于我正在使用大量的NSData字节,我不想制作大的副本,而只是截断现有的字节.基本上:

  • NSData*source:<我要丢弃的几个字节> + <我要保留的大块字节>
  • NSData*destination:<我要保留的大块字节>

NSMutableData中有截断方法,但它们只截断它的结尾,而我想截断开头.我的想法是用这些方法做到这一点:

请注意,我在原始发布中使用了错误的(复制)方法.我已经编辑并修复了它

- (const void *)bytes
Run Code Online (Sandbox Code Playgroud)

- initWithBytesNoCopy:length:freeWhenDone:
Run Code Online (Sandbox Code Playgroud)

但是,我正在试图弄清楚如何用这些管理内存.我猜这个过程会是这样的(我把它放在哪里,我不知道该怎么做):

// Get bytes
const unsigned char *bytes = (const unsigned char *)[source bytes];

// Offset the start
bytes += myStart;

// Somehow (m)alloc the memory which will be freed up in the following step
?????

// Release the source, now that I've allocated the bytes
[source release];

// Create a new data, recycling the bytes so they don't have to be copied
NSData destination = …
Run Code Online (Sandbox Code Playgroud)

truncate nsdata nsmutabledata

2
推荐指数
1
解决办法
1万
查看次数

使用swank + leiningen + emacs时如何在保存时重新加载文件

我想设置slime + lein-swank来重新加载当我保存文件时从repl引用的源文件.目前我这样做:

  • 编辑文件
  • 保存存档
  • 切换到repl
  • (使用:reload-all'com.package.namespace)
  • 测试的东西

我想不必记得做第4步.

emacs clojure slime leiningen

22
推荐指数
3
解决办法
2654
查看次数

关于Nullable <T>约束的困惑

向大家致以问候.对不起,如果以前已经问过这个问题(徒劳无功),或者说非常简单,但我无法得到它.Nullable类型的MSDN定义声明它是以下列方式定义的:

[SerializableAttribute]
public struct Nullable<T>
where T : struct, new()
Run Code Online (Sandbox Code Playgroud)

所以问题非常简单:这个定义怎么可能?或者这只是一个错字?每个值类型都有一个默认构造函数.实际上,当我尝试编译这样的东西时,编译器合理地说,同时应用两个约束是非法的,因为第二个隐含地包含在第一个约束中.

提前致谢.

.net c# nullable

10
推荐指数
2
解决办法
357
查看次数

从toString转换回Object

有没有办法从toString转换回Java中的对象?

例如:

Map<String, String> myMap = new HashMap<String, String>();
myMap.put("value1", "test1");
myMap.put("value2", "test2");
String str = myMap.toString();
Run Code Online (Sandbox Code Playgroud)

有没有办法将此String转换回Map?

java

4
推荐指数
1
解决办法
8925
查看次数

java.util.zip:putNextEntry

我正在尝试使用java.util.net修改zip文件中的文件.因为不可能直接修改文件而我只想修改一个文件,所以我只创建一个新的zip文件,其中基本上包含了模板并替换特定文件,至少是计划.

以下是我尝试的最重要的部分:

Enumeration<? extends ZipEntry> entries = zif.entries();
while (entries.hasMoreElements()) {
ZipEntry currentEntry = entries.nextElement();
if (!currentEntry.isDirectory() && currentEntry.getSize() >0 && currentEntry.getCompressedSize() > 0)
{
    System.out.println(currentEntry.getName() + ": " + currentEntry.getSize() + "-" + currentEntry.getMethod());
    if (currentEntry.getName() != "file_i_want_to_change")
    {
        try {
            this.zos.putNextEntry(currentEntry);  // HERE the exception is thrown
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println(e.getMessage());
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

信息:zif = ZipFile,正确实例化并从现有文件打开; zos = ZipOutputStream,正确地为新文件实例化.

这是抛出的异常:

java.util.zip.ZipException: invalid entry size (expected 39 but got 0 bytes)
at java.util.zip.ZipOutputStream.closeEntry(ZipOutputStream.java:228)
at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:144) …
Run Code Online (Sandbox Code Playgroud)

java zip

3
推荐指数
1
解决办法
5967
查看次数

为什么我不能向引用Itself的集合中的每个元素添加事件,而不是"for(){}"语句中的最后一个元素

Window的负荷,每一个DD元素中Quote_App应该有一个onCLick触发功能追加事件Lorem,然而,Lorem返回nodeNameId在最后一个元素的For声明,而不是该触发功能的元素.我想要Lorem返回触发该函数的元素nodeNameId.

function Lorem(Control){

/*     this.Control=Control; */
    this.Amet=function(){
        return Control.nodeName+"\n"+Control.id;
    };

};

function Event(Mode,Function,Event,Element,Capture_or_Bubble){
    if(Mode.toLowerCase()!="remove"){
        if(Element.addEventListener){
            if(!Capture_or_Bubble){
                Capture_or_Bubble=false;
            }else{
                if(Capture_or_Bubble.toLowerCase()!="true"){
                    Capture_or_Bubble=false;
                }else{
                    Capture_or_Bubble=true;
                };
            };
            Element.addEventListener(Event,Function,Capture_or_Bubble);
        }else{
            Element.attachEvent("on"+Event,Function);
        };
    };
};

function Controls(){
    var Controls=document.getElementById("Quote_App").getElementsByTagName("dd");
    for(var i=0;i<Controls.length;i++){

        var Control=Controls[i];

        Event("add",function(){

            var lorem=new Lorem(Control);
            lorem.Control=Control;
            alert(lorem.Amet());

        },"click",Controls[i]);

    };
};

Event("add",Controls,"load",window);
Run Code Online (Sandbox Code Playgroud)

目前你点击任何DD元素Lorem总是返回nodeNameId …

javascript foreach addeventlistener getelementsbytagname

3
推荐指数
1
解决办法
141
查看次数

启动时出现Eclipse错误

Eclipse昨晚运行正常,但今天早上我尝试启动它,我发现了这个错误:

替代文字http://img707.imageshack.us/img707/4416/ss20100407181208.png

这是日志

!SESSION 2010-04-07 17:58:37.208 -----------------------------------------------
eclipse.buildId=I20080617-2000
java.version=1.6.0_13
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86

!ENTRY org.eclipse.osgi 4 0 2010-04-07 17:58:37.457
!MESSAGE Startup error
!STACK 1
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at org.eclipse.osgi.storagemanager.StorageManager.updateTable(StorageManager.java:512)
at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:694)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initFileManager(BaseStorage.java:208)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initialize(BaseStorage.java:142)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.initializeStorage(BaseAdaptor.java:124)
at org.eclipse.osgi.framework.internal.core.Framework.initialize(Framework.java:180)
at org.eclipse.osgi.framework.internal.core.Framework.<init>(Framework.java:152)
at org.eclipse.osgi.framework.internal.core.OSGi.createFramework(OSGi.java:90)
at org.eclipse.osgi.framework.internal.core.OSGi.<init>(OSGi.java:31)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:286)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at …
Run Code Online (Sandbox Code Playgroud)

eclipse workspace ganymede eclipse-3.4

5
推荐指数
3
解决办法
8153
查看次数

动态URL - > Rails中路由的控制器映射

我希望能够根据数据库中的信息动态地将URL映射到控制器.

我正在寻找功能相当的东西(假设一个View模型):

map.route '/:view_name',
    :controller => lambda { View.find_by_name(params[:view_name]).controller }
Run Code Online (Sandbox Code Playgroud)

其他人建议动态重建路由,但这对我不起作用,因为可能有数千个视图映射到同一个Controller

model-view-controller ruby-on-rails url-routing

14
推荐指数
2
解决办法
5178
查看次数

CSS水平滚动框

我试图创建一个水平滚动框来创建一个"时间轴"效果...但我似乎无法让它水平滚动,而垂直滚动条显示...想法?

#container{
     width:500px;
     height:250px;
     border:1px solid #cc61b8;
     overflow:auto;
}

.container-bits{
    width:250px;
    height:498px;
    float:left;
}

<div id="container">
     <div class="container-bits">Content Here</div>
     <div class="container-bits">Content Here</div>
     <div class="container-bits">Content Here</div>
     <div class="container-bits">Content Here</div>
     <div class="container-bits">Content Here</div>
     <div class="container-bits">Content Here</div>
</div>
Run Code Online (Sandbox Code Playgroud)

css scroll

1
推荐指数
1
解决办法
4466
查看次数