Skip to content

Commit ba0ba5e

Browse files
committed
merge default into bug22772
2 parents 74c7849 + 9e01ceb commit ba0ba5e

File tree

11 files changed

+337
-212
lines changed

11 files changed

+337
-212
lines changed

RabbitMQDotNetClient.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RabbitMQ.Client.Examples.Sh
6060
EndProject
6161
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RabbitMQ.Client.Examples.PerfTest", "projects\examples\client\PerfTest\RabbitMQ.Client.Examples.PerfTest.csproj", "{6ED176D6-B789-4673-8300-CB671962FE00}"
6262
EndProject
63+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RabbitMQ.Client.Examples.Subscriber", "projects\examples\client\Subscriber\RabbitMQ.Client.Examples.Subscriber.csproj", "{F6DF1899-A038-4DBF-86D0-0DE64F2422EC}"
64+
EndProject
6365
Global
6466
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6567
Debug|Any CPU = Debug|Any CPU
@@ -192,6 +194,12 @@ Global
192194
{6ED176D6-B789-4673-8300-CB671962FE00}.DebugNoTest|Any CPU.Build.0 = Debug|Any CPU
193195
{6ED176D6-B789-4673-8300-CB671962FE00}.Release|Any CPU.ActiveCfg = Release|Any CPU
194196
{6ED176D6-B789-4673-8300-CB671962FE00}.Release|Any CPU.Build.0 = Release|Any CPU
197+
{F6DF1899-A038-4DBF-86D0-0DE64F2422EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
198+
{F6DF1899-A038-4DBF-86D0-0DE64F2422EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
199+
{F6DF1899-A038-4DBF-86D0-0DE64F2422EC}.DebugNoTest|Any CPU.ActiveCfg = Debug|Any CPU
200+
{F6DF1899-A038-4DBF-86D0-0DE64F2422EC}.DebugNoTest|Any CPU.Build.0 = Debug|Any CPU
201+
{F6DF1899-A038-4DBF-86D0-0DE64F2422EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
202+
{F6DF1899-A038-4DBF-86D0-0DE64F2422EC}.Release|Any CPU.Build.0 = Release|Any CPU
195203
EndGlobalSection
196204
GlobalSection(SolutionProperties) = preSolution
197205
HideSolutionNode = FALSE
@@ -219,6 +227,7 @@ Global
219227
{44D14FF0-1015-4AAA-ABCA-BF611879816C} = {78D13AD2-B1AC-442C-95C8-958D643FC40B}
220228
{8BCE15DB-C92F-4FA4-AE57-9CA73DE91EB2} = {78D13AD2-B1AC-442C-95C8-958D643FC40B}
221229
{6ED176D6-B789-4673-8300-CB671962FE00} = {78D13AD2-B1AC-442C-95C8-958D643FC40B}
230+
{F6DF1899-A038-4DBF-86D0-0DE64F2422EC} = {78D13AD2-B1AC-442C-95C8-958D643FC40B}
222231
{20E34D9F-EE72-4B55-B6FE-1D0DBE5B74CD} = {EA42A7EF-7CE6-4EDA-98EA-6675C7EF7F69}
223232
{39CA1299-1F9E-452E-AA00-4BF874944B1E} = {EA42A7EF-7CE6-4EDA-98EA-6675C7EF7F69}
224233
{201B37E1-9BFC-4A01-9760-30C5BB19CFE3} = {20E34D9F-EE72-4B55-B6FE-1D0DBE5B74CD}

docs/wikipages/data.MessagingPatterns.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,22 +382,22 @@ on class [code RabbitMQ.Client.IModel].
382382

383383
The class [code RabbitMQ.Client.MessagePatterns.Subscription]
384384
implements most of the boilerplate of receiving messages (including,
385-
in particular, broadcast events) for you, including queue and exchange
386-
declaration and queue binding, as well as consumer declaration and
387-
management. For example,
385+
in particular, broadcast events) for you, including consumer
386+
declaration and management, but excluding queue and exchange
387+
declaration and queue binding. For example,
388388

389389
@code java
390390
// "IModel ch" in scope.
391-
Subscription sub = new Subscription(ch, "price", "topic", "STOCK.IBM.#");
391+
Subscription sub = new Subscription(ch, "STOCK.IBM.#");
392392
foreach (BasicDeliverEventArgs e in sub) {
393393
// handle the message contained in e ...
394394
// ... and finally acknowledge it
395395
sub.Ack(e);
396396
}
397397

398-
will declare the relevant exchange, declare a temporary queue, bind
399-
the two together, and start a consumer on the queue using [code
400-
IModel.BasicConsume].
398+
will start a consumer on the queue using [code IModel.BasicConsume].
399+
It is assumed that the queue and any bindings have been previously
400+
declared.
401401

402402
[code Subscription.Ack()] should be called for each received event,
403403
whether or not auto-acknowledgement mode is used, because [code

projects/client/Apigen/src/apigen/Apigen.cs

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public static string MangleMethodClass(AmqpClass c, AmqpMethod m) {
196196
public static Hashtable m_primitiveTypeFlagMap;
197197
static Apigen() {
198198
m_primitiveTypeMap = new Hashtable();
199-
m_primitiveTypeFlagMap = new Hashtable();
199+
m_primitiveTypeFlagMap = new Hashtable();
200200
InitPrimitiveType("octet", "byte", false);
201201
InitPrimitiveType("shortstr", "string", true);
202202
InitPrimitiveType("longstr", "byte[]", true);
@@ -209,11 +209,11 @@ static Apigen() {
209209
InitPrimitiveType("content", "byte[]", true);
210210
}
211211

212-
public static void InitPrimitiveType(string amqpType, string dotnetType, bool isReference)
213-
{
214-
m_primitiveTypeMap[amqpType] = dotnetType;
215-
m_primitiveTypeFlagMap[amqpType] = isReference;
216-
}
212+
public static void InitPrimitiveType(string amqpType, string dotnetType, bool isReference)
213+
{
214+
m_primitiveTypeMap[amqpType] = dotnetType;
215+
m_primitiveTypeFlagMap[amqpType] = isReference;
216+
}
217217

218218
public void HandleOption(string opt) {
219219
if (opt.StartsWith("/n:")) {
@@ -284,7 +284,7 @@ public string ImplNamespaceBase {
284284
public void Generate() {
285285
LoadSpec();
286286
ParseSpec();
287-
ReflectModel();
287+
ReflectModel();
288288
GenerateOutput();
289289
}
290290

@@ -360,7 +360,7 @@ public void Emit(object o) {
360360
public void EmitLine(object o) {
361361
m_outputFile.WriteLine(o);
362362
}
363-
363+
364364
public void EmitSpecComment(object o) {
365365
if (m_emitComments)
366366
EmitLine(o);
@@ -498,13 +498,13 @@ public bool HasFactoryMethod(AmqpClass c) {
498498
return false;
499499
}
500500

501-
public bool IsBoolean(AmqpField f) {
502-
return ResolveDomain(f.Domain) == "bit";
503-
}
501+
public bool IsBoolean(AmqpField f) {
502+
return ResolveDomain(f.Domain) == "bit";
503+
}
504504

505-
public bool IsReferenceType(AmqpField f) {
506-
return (bool) m_primitiveTypeFlagMap[ResolveDomain(f.Domain)];
507-
}
505+
public bool IsReferenceType(AmqpField f) {
506+
return (bool) m_primitiveTypeFlagMap[ResolveDomain(f.Domain)];
507+
}
508508

509509
public bool IsAmqpClass(Type t)
510510
{
@@ -517,12 +517,12 @@ public bool IsAmqpClass(Type t)
517517
}
518518

519519
public void EmitClassProperties(AmqpClass c) {
520-
bool hasCommonApi = HasFactoryMethod(c);
521-
string propertiesBaseClass =
522-
hasCommonApi
523-
? "RabbitMQ.Client.Impl."+MangleClass(c.Name)+"Properties"
524-
: "RabbitMQ.Client.Impl.ContentHeaderBase";
525-
string maybeOverride = hasCommonApi ? "override " : "";
520+
bool hasCommonApi = HasFactoryMethod(c);
521+
string propertiesBaseClass =
522+
hasCommonApi
523+
? "RabbitMQ.Client.Impl."+MangleClass(c.Name)+"Properties"
524+
: "RabbitMQ.Client.Impl.ContentHeaderBase";
525+
string maybeOverride = hasCommonApi ? "override " : "";
526526

527527
EmitAutogeneratedSummary(" ",
528528
"AMQP specification content header properties for "+
@@ -536,9 +536,9 @@ public void EmitClassProperties(AmqpClass c) {
536536
EmitLine("");
537537
foreach (AmqpField f in c.m_Fields)
538538
{
539-
if (!IsBoolean(f)) {
540-
EmitLine(" private bool m_"+MangleMethod(f.Name)+"_present = false;");
541-
}
539+
if (!IsBoolean(f)) {
540+
EmitLine(" private bool m_"+MangleMethod(f.Name)+"_present = false;");
541+
}
542542
}
543543
EmitLine("");
544544
foreach (AmqpField f in c.m_Fields)
@@ -549,19 +549,19 @@ public void EmitClassProperties(AmqpClass c) {
549549
EmitLine(" return m_"+MangleMethod(f.Name)+";");
550550
EmitLine(" }");
551551
EmitLine(" set {");
552-
if (!IsBoolean(f)) {
553-
EmitLine(" m_"+MangleMethod(f.Name)+"_present = true;");
554-
}
552+
if (!IsBoolean(f)) {
553+
EmitLine(" m_"+MangleMethod(f.Name)+"_present = true;");
554+
}
555555
EmitLine(" m_"+MangleMethod(f.Name)+" = value;");
556556
EmitLine(" }");
557557
EmitLine(" }");
558558
}
559559
EmitLine("");
560560
foreach (AmqpField f in c.m_Fields)
561561
{
562-
if (!IsBoolean(f)) {
563-
EmitLine(" public "+maybeOverride+"void Clear"+MangleClass(f.Name)+"() { m_"+MangleMethod(f.Name)+"_present = false; }");
564-
}
562+
if (!IsBoolean(f)) {
563+
EmitLine(" public "+maybeOverride+"void Clear"+MangleClass(f.Name)+"() { m_"+MangleMethod(f.Name)+"_present = false; }");
564+
}
565565
}
566566

567567
EmitLine("");
@@ -579,36 +579,36 @@ public void EmitClassProperties(AmqpClass c) {
579579
EmitLine(" public override void ReadPropertiesFrom(RabbitMQ.Client.Impl.ContentHeaderPropertyReader reader) {");
580580
foreach (AmqpField f in c.m_Fields)
581581
{
582-
if (IsBoolean(f)) {
583-
EmitLine(" m_"+MangleMethod(f.Name)+" = reader.ReadBit();");
584-
} else {
585-
EmitLine(" m_"+MangleMethod(f.Name)+"_present = reader.ReadPresence();");
586-
}
582+
if (IsBoolean(f)) {
583+
EmitLine(" m_"+MangleMethod(f.Name)+" = reader.ReadBit();");
584+
} else {
585+
EmitLine(" m_"+MangleMethod(f.Name)+"_present = reader.ReadPresence();");
586+
}
587587
}
588-
EmitLine(" reader.FinishPresence();");
588+
EmitLine(" reader.FinishPresence();");
589589
foreach (AmqpField f in c.m_Fields)
590590
{
591-
if (!IsBoolean(f)) {
592-
EmitLine(" if (m_"+MangleMethod(f.Name)+"_present) { m_"+MangleMethod(f.Name)+" = reader.Read"+MangleClass(ResolveDomain(f.Domain))+"(); }");
593-
}
591+
if (!IsBoolean(f)) {
592+
EmitLine(" if (m_"+MangleMethod(f.Name)+"_present) { m_"+MangleMethod(f.Name)+" = reader.Read"+MangleClass(ResolveDomain(f.Domain))+"(); }");
593+
}
594594
}
595595
EmitLine(" }");
596596
EmitLine("");
597597
EmitLine(" public override void WritePropertiesTo(RabbitMQ.Client.Impl.ContentHeaderPropertyWriter writer) {");
598598
foreach (AmqpField f in c.m_Fields)
599599
{
600-
if (IsBoolean(f)) {
601-
EmitLine(" writer.WriteBit(m_"+MangleMethod(f.Name)+");");
602-
} else {
603-
EmitLine(" writer.WritePresence(m_"+MangleMethod(f.Name)+"_present);");
604-
}
600+
if (IsBoolean(f)) {
601+
EmitLine(" writer.WriteBit(m_"+MangleMethod(f.Name)+");");
602+
} else {
603+
EmitLine(" writer.WritePresence(m_"+MangleMethod(f.Name)+"_present);");
604+
}
605605
}
606-
EmitLine(" writer.FinishPresence();");
606+
EmitLine(" writer.FinishPresence();");
607607
foreach (AmqpField f in c.m_Fields)
608608
{
609-
if (!IsBoolean(f)) {
610-
EmitLine(" if (m_"+MangleMethod(f.Name)+"_present) { writer.Write"+MangleClass(ResolveDomain(f.Domain))+"(m_"+MangleMethod(f.Name)+"); }");
611-
}
609+
if (!IsBoolean(f)) {
610+
EmitLine(" if (m_"+MangleMethod(f.Name)+"_present) { writer.Write"+MangleClass(ResolveDomain(f.Domain))+"(m_"+MangleMethod(f.Name)+"); }");
611+
}
612612
}
613613
EmitLine(" }");
614614
EmitLine("");
@@ -619,16 +619,16 @@ public void EmitClassProperties(AmqpClass c) {
619619
foreach (AmqpField f in c.m_Fields)
620620
{
621621
Emit(" sb.Append(\""+f.Name+"=\");");
622-
if (IsBoolean(f)) {
623-
Emit(" sb.Append(m_"+MangleMethod(f.Name)+");");
624-
} else {
625-
string x = MangleMethod(f.Name);
626-
if (IsReferenceType(f)) {
627-
Emit(" sb.Append(m_"+x+"_present ? (m_"+x+" == null ? \"(null)\" : m_"+x+".ToString()) : \"_\");");
628-
} else {
629-
Emit(" sb.Append(m_"+x+"_present ? m_"+x+".ToString() : \"_\");");
630-
}
631-
}
622+
if (IsBoolean(f)) {
623+
Emit(" sb.Append(m_"+MangleMethod(f.Name)+");");
624+
} else {
625+
string x = MangleMethod(f.Name);
626+
if (IsReferenceType(f)) {
627+
Emit(" sb.Append(m_"+x+"_present ? (m_"+x+" == null ? \"(null)\" : m_"+x+".ToString()) : \"_\");");
628+
} else {
629+
Emit(" sb.Append(m_"+x+"_present ? m_"+x+".ToString() : \"_\");");
630+
}
631+
}
632632
remaining--;
633633
if (remaining > 0) {
634634
EmitLine(" sb.Append(\", \");");
@@ -849,12 +849,12 @@ public void EmitModelImplementation() {
849849
EmitLine(" }");
850850
}
851851

852-
public void EmitContentHeaderFactory(MethodInfo method) {
853-
AmqpContentHeaderFactoryAttribute factoryAnnotation = (AmqpContentHeaderFactoryAttribute)
854-
Attribute(method, typeof(AmqpContentHeaderFactoryAttribute));
855-
string contentClass = factoryAnnotation.m_contentClass;
856-
EmitModelMethodPreamble(method);
857-
EmitLine(" {");
852+
public void EmitContentHeaderFactory(MethodInfo method) {
853+
AmqpContentHeaderFactoryAttribute factoryAnnotation = (AmqpContentHeaderFactoryAttribute)
854+
Attribute(method, typeof(AmqpContentHeaderFactoryAttribute));
855+
string contentClass = factoryAnnotation.m_contentClass;
856+
EmitModelMethodPreamble(method);
857+
EmitLine(" {");
858858
if (Attribute(method, typeof(AmqpUnsupportedAttribute)) != null)
859859
{
860860
EmitLine(String.Format(" throw new UnsupportedMethodException(\"" + method.Name + "\");"));
@@ -863,17 +863,17 @@ public void EmitContentHeaderFactory(MethodInfo method) {
863863
{
864864
EmitLine(" return new " + MangleClass(contentClass) + "Properties();");
865865
}
866-
EmitLine(" }");
867-
}
866+
EmitLine(" }");
867+
}
868868

869869
public void MaybeEmitModelMethod(MethodInfo method) {
870870
if (method.IsSpecialName) {
871871
// It's some kind of event- or property-related method.
872872
// It shouldn't be autogenerated.
873873
} else if (Attribute(method, typeof(AmqpMethodDoNotImplementAttribute)) != null) {
874874
// Skip this method, by request (AmqpMethodDoNotImplement)
875-
} else if (Attribute(method, typeof(AmqpContentHeaderFactoryAttribute)) != null) {
876-
EmitContentHeaderFactory(method);
875+
} else if (Attribute(method, typeof(AmqpContentHeaderFactoryAttribute)) != null) {
876+
EmitContentHeaderFactory(method);
877877
} else if (Attribute(method, typeof(AmqpUnsupportedAttribute)) != null) {
878878
EmitModelMethodPreamble(method);
879879
EmitLine(" {");
@@ -919,7 +919,7 @@ public void LookupAmqpMethod(MethodInfo method,
919919
{
920920
amqpClass = null;
921921
amqpMethod = null;
922-
922+
923923
// First, try autodetecting the class/method via the
924924
// IModel method name.
925925

@@ -1136,7 +1136,7 @@ public void EmitAsynchronousHandlers(ArrayList asynchronousHandlers) {
11361136
EmitLine(" case "+((amqpClass.Index << 16) | amqpMethod.Index)+": {");
11371137
ParameterInfo[] parameters = method.GetParameters();
11381138
if (parameters.Length > 0) {
1139-
EmitLine(" "+implClass+" __impl = ("+implClass+") __method;");
1139+
EmitLine(" "+implClass+" __impl = ("+implClass+") __method;");
11401140
EmitLine(" "+method.Name+"(");
11411141
int remaining = parameters.Length;
11421142
foreach (ParameterInfo pi in parameters) {

projects/client/RabbitMQ.Client/src/client/api/IModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ void HandleBasicReturn(ushort replyCode,
646646
///<summary>Used to send a Channel.FlowOk. Confirms that
647647
///Channel.Flow from the broker was processed.</summary>
648648
[AmqpMethodMapping(null, "channel", "flow-ok")]
649-
void _Private_ChannelFlowOk();
649+
void _Private_ChannelFlowOk(bool active);
650650

651651
///<summary>Handle incoming Channel.Flow methods. Either
652652
///stops or resumes sending the methods that have content.</summary>

projects/client/RabbitMQ.Client/src/client/impl/ModelBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,15 +402,15 @@ public void HandleBasicReturn(ushort replyCode,
402402
OnBasicReturn(e);
403403
}
404404

405-
public abstract void _Private_ChannelFlowOk();
405+
public abstract void _Private_ChannelFlowOk(bool active);
406406

407407
public void HandleChannelFlow(bool active)
408408
{
409409
if (active)
410410
m_flowControlBlock.Set();
411411
else
412412
m_flowControlBlock.Reset();
413-
_Private_ChannelFlowOk();
413+
_Private_ChannelFlowOk(active);
414414
}
415415

416416
public void HandleConnectionStart(byte versionMajor,

projects/client/RabbitMQ.Client/src/client/messagepatterns/SimpleRpcClient.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,16 @@ namespace RabbitMQ.Client.MessagePatterns {
8787
/// SimpleRpcClient client =
8888
/// new SimpleRpcClient(ch, queueName);
8989
/// client.TimeoutMilliseconds = 5000; // optional
90-
///
90+
///
9191
/// /// ... make use of the various Call() overloads
9292
/// }
9393
/// }
9494
///</code></example>
9595
///<para>
96-
/// Instances of this class do not themselves declare any
97-
/// resources (exchanges, queues or bindings). The Subscription we
98-
/// use for receiving RPC replies declares its own resources
99-
/// (usually a single queue), but if we are sending to an exchange
100-
/// other than one of the AMQP-standard mandated predefined
101-
/// exchanges, it is the user's responsibility to ensure that the
102-
/// exchange concerned exists (using IModel.ExchangeDeclare)
103-
/// before invoking Call() or Cast().
96+
/// Instances of this class declare a queue, so it is the user's
97+
/// responsibility to ensure that the exchange concerned exists
98+
/// (using IModel.ExchangeDeclare) before invoking Call() or
99+
/// Cast().
104100
///</para>
105101
///<para>
106102
/// This class implements only a few basic RPC message formats -
@@ -235,7 +231,8 @@ public void Close()
235231
protected virtual void EnsureSubscription()
236232
{
237233
if (m_subscription == null) {
238-
m_subscription = new Subscription(m_model);
234+
string queueName = m_model.QueueDeclare();
235+
m_subscription = new Subscription(m_model, queueName);
239236
}
240237
}
241238

0 commit comments

Comments
 (0)