Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
cb86c952
Commit
cb86c952
authored
Nov 27, 2019
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support null value of message body.
parent
971c9db9
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
16 deletions
+25
-16
ITransport.Kafka.cs
src/DotNetCore.CAP.Kafka/ITransport.Kafka.cs
+0
-1
ICapPublisher.cs
src/DotNetCore.CAP/ICapPublisher.cs
+10
-9
IConsumerInvoker.Default.cs
src/DotNetCore.CAP/Internal/IConsumerInvoker.Default.cs
+1
-1
Message.cs
src/DotNetCore.CAP/Messages/Message.cs
+4
-2
TransportMessage.cs
src/DotNetCore.CAP/Messages/TransportMessage.cs
+4
-2
ISerializer.JsonUtf8.cs
src/DotNetCore.CAP/Serialization/ISerializer.JsonUtf8.cs
+6
-1
No files found.
src/DotNetCore.CAP.Kafka/ITransport.Kafka.cs
View file @
cb86c952
...
...
@@ -2,7 +2,6 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
using
System
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Confluent.Kafka
;
...
...
src/DotNetCore.CAP/ICapPublisher.cs
View file @
cb86c952
...
...
@@ -5,6 +5,7 @@ using System;
using
System.Collections.Generic
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
JetBrains.Annotations
;
namespace
DotNetCore.CAP
{
...
...
@@ -24,35 +25,35 @@ namespace DotNetCore.CAP
/// Asynchronous publish an object message.
/// </summary>
/// <param name="name">the topic name or exchange router key.</param>
/// <param name="contentObj">message body content, that will be serialized.</param>
/// <param name="contentObj">message body content, that will be serialized.
(can be null)
</param>
/// <param name="callbackName">callback subscriber name</param>
/// <param name="cancellationToken"></param>
Task
PublishAsync
<
T
>(
string
name
,
T
contentObj
,
string
callbackName
=
null
,
CancellationToken
cancellationToken
=
default
);
Task
PublishAsync
<
T
>(
string
name
,
[
CanBeNull
]
T
contentObj
,
string
callbackName
=
null
,
CancellationToken
cancellationToken
=
default
);
/// <summary>
/// Asynchronous publish an object message with custom headers
/// </summary>
/// <typeparam name="T">content object</typeparam>
/// <param name="name">the topic name or exchange router key.</param>
/// <param name="contentObj">message body content, that will be serialized.</param>
/// <param name="contentObj">message body content, that will be serialized.
(can be null)
</param>
/// <param name="headers">message additional headers.</param>
/// <param name="cancellationToken"></param>
Task
PublishAsync
<
T
>(
string
name
,
T
contentObj
,
IDictionary
<
string
,
string
>
headers
,
CancellationToken
cancellationToken
=
default
);
Task
PublishAsync
<
T
>(
string
name
,
[
CanBeNull
]
T
contentObj
,
IDictionary
<
string
,
string
>
headers
,
CancellationToken
cancellationToken
=
default
);
/// <summary>
/// Publish an object message.
/// </summary>
/// <param name="name">the topic name or exchange router key.</param>
/// <param name="contentObj">message body content, that will be serialized
of json.
</param>
/// <param name="contentObj">message body content, that will be serialized
. (can be null)
</param>
/// <param name="callbackName">callback subscriber name</param>
void
Publish
<
T
>(
string
name
,
T
contentObj
,
string
callbackName
=
null
);
void
Publish
<
T
>(
string
name
,
[
CanBeNull
]
T
contentObj
,
string
callbackName
=
null
);
/// <summary>
/// Publish an object message.
/// </summary>
/// <param name="name">the topic name or exchange router key.</param>
/// <param name="contentObj">message body content, that will be serialized
of json.
</param>
/// <param name="contentObj">message body content, that will be serialized
. (can be null)
</param>
/// <param name="headers">message additional headers.</param>
void
Publish
<
T
>(
string
name
,
T
contentObj
,
IDictionary
<
string
,
string
>
headers
);
void
Publish
<
T
>(
string
name
,
[
CanBeNull
]
T
contentObj
,
IDictionary
<
string
,
string
>
headers
);
}
}
\ No newline at end of file
src/DotNetCore.CAP/Internal/IConsumerInvoker.Default.cs
View file @
cb86c952
src/DotNetCore.CAP/Messages/Message.cs
View file @
cb86c952
using
System
;
using
System.Collections.Generic
;
using
JetBrains.Annotations
;
namespace
DotNetCore.CAP.Messages
{
public
class
Message
{
public
Message
(
IDictionary
<
string
,
string
>
headers
,
object
value
)
public
Message
(
IDictionary
<
string
,
string
>
headers
,
[
CanBeNull
]
object
value
)
{
Headers
=
headers
??
throw
new
ArgumentNullException
(
nameof
(
headers
));
Value
=
value
??
throw
new
ArgumentNullException
(
nameof
(
value
))
;
Value
=
value
;
}
public
IDictionary
<
string
,
string
>
Headers
{
get
;
}
[
CanBeNull
]
public
object
Value
{
get
;
}
}
...
...
src/DotNetCore.CAP/Messages/TransportMessage.cs
View file @
cb86c952
using
System
;
using
System.Collections.Generic
;
using
JetBrains.Annotations
;
namespace
DotNetCore.CAP.Messages
{
...
...
@@ -8,10 +9,10 @@ namespace DotNetCore.CAP.Messages
/// </summary>
public
class
TransportMessage
{
public
TransportMessage
(
IDictionary
<
string
,
string
>
headers
,
byte
[]
body
)
public
TransportMessage
(
IDictionary
<
string
,
string
>
headers
,
[
CanBeNull
]
byte
[]
body
)
{
Headers
=
headers
??
throw
new
ArgumentNullException
(
nameof
(
headers
));
Body
=
body
??
throw
new
ArgumentNullException
(
nameof
(
body
))
;
Body
=
body
;
}
/// <summary>
...
...
@@ -22,6 +23,7 @@ namespace DotNetCore.CAP.Messages
/// <summary>
/// Gets the body object of this message
/// </summary>
[
CanBeNull
]
public
byte
[]
Body
{
get
;
}
public
string
GetId
()
...
...
src/DotNetCore.CAP/Serialization/ISerializer.JsonUtf8.cs
View file @
cb86c952
...
...
@@ -13,13 +13,18 @@ namespace DotNetCore.CAP.Serialization
{
public
Task
<
TransportMessage
>
SerializeAsync
(
Message
message
)
{
if
(
message
.
Value
==
null
)
{
return
Task
.
FromResult
(
new
TransportMessage
(
message
.
Headers
,
null
));
}
var
json
=
JsonConvert
.
SerializeObject
(
message
.
Value
);
return
Task
.
FromResult
(
new
TransportMessage
(
message
.
Headers
,
Encoding
.
UTF8
.
GetBytes
(
json
)));
}
public
Task
<
Message
>
DeserializeAsync
(
TransportMessage
transportMessage
,
Type
valueType
)
{
if
(
valueType
==
null
)
if
(
valueType
==
null
||
transportMessage
.
Body
==
null
)
{
return
Task
.
FromResult
(
new
Message
(
transportMessage
.
Headers
,
null
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment