我现在正在寻找解决方案如何在Java客户端中使用 chunked 传输编码,而无需编写自己的 USE StackOverflow
GO
IF OBJECT_ID('dbo.tblAddress', 'U') IS NOT NULL
DROP TABLE dbo.tblAddress
CREATE TABLE tblAddress
(
Id INT IDENTITY PRIMARY KEY,
[Address] VARCHAR(128)
)
IF OBJECT_ID('dbo.tblAddressAudit', 'U') IS NOT NULL
DROP TABLE dbo.tblAddressAudit
CREATE TABLE tblAddressAudit
(
Id INT IDENTITY PRIMARY KEY,
AddressID INT,
[Address] VARCHAR(128),
AuditDate DATETIME,
[Action] CHAR(1)
)
IF OBJECT_ID('dbo.tblAddress_audit_trigger', 'U') IS NOT NULL
DROP TRIGGER dbo.tblAddress_audit_trigger
GO
CREATE TRIGGER dbo.tblAddress_audit_trigger
ON dbo.tblAddress
AFTER INSERT, UPDATE, DELETE
AS
BEGIN
SET NOCOUNT ON;
IF EXISTS(SELECT 1 FROM deleted)
BEGIN
INSERT INTO dbo.tblAddressAudit
SELECT d.Id AS AddressID, d.[Address], GETDATE() AuditDate, 'D' [Action]
FROM deleted d
LEFT JOIN inserted i ON i.Id = d.Id
WHERE i.Id IS NULL
END
ELSE IF EXISTS(SELECT 1 FROM inserted)
BEGIN
INSERT INTO dbo.tblAddressAudit
SELECT i.Id AS AddressID, i.[Address], GETDATE() AuditDate, 'I' [Action]
FROM inserted i
LEFT JOIN deleted d ON i.Id = d.Id
WHERE d.Id IS NULL
END
IF EXISTS(SELECT 1 FROM inserted i JOIN deleted d on i.Id = d.Id)
BEGIN
INSERT INTO dbo.tblAddressAudit
SELECT i.Id AS AddressID, i.[Address], GETDATE() AuditDate, 'U' [Action]
FROM inserted i
JOIN deleted d on i.Id = d.Id
END
END
GO
INSERT INTO dbo.tblAddress
VALUES
(
'42 Goble street'
)
GO
UPDATE dbo.tblAddress
SET [Address] ='43 Goble St'
WHERE Id = 1
GO
DELETE FROM dbo.tblAddress
WHERE Id = 1
GO
。
Java的 myHttpURLConnection
需要固定的块大小,这对我来说无法使用。数据由几个大小不同的消息组成,必须在neartime中发送到服务器。当前(在Prelive / UAT状态下)系统基于具有固定HttpUrlConnection
块的工作,但由于大多数消息明显更短,因此浪费了PROD中不可接受的带宽。
此外,大于1024 byte
的消息将被切断,因此a)服务器需要再次组装它们; b)在有足够的数据可用于填充之前,不会发送消息的最后部分{{ 1}}(更糟糕的是,不再是时间了)。
有没有人知道如何解决Java 1024 bytes
的限制(不符合 RFC2616 ,因为它没有完全实现它)而不必编写所有内容的代码的 1024 bytes
?
我没有找到任何可能挂钩所需的funcs,只为每个数据堆设置一个新的块大小。
我当前的选项:将所有HttpUrlConnection
代码兼容并修改处理 CHUNKED 的部分(例如,有一些 flush()函数调整块大小并发送其中的内容。